我有一个设备想做一个自动安装的程序,目前只有inf 文件和驱动文件
如何做成一个setup文件,让他自动安装!
如何做成一个setup文件,让他自动安装!
解决方案 »
- InstallShield X Express v10.0.SP2 制作安装包时想加入安装google工具栏的功能。救命,今晚得有结果,谢谢各位高手!
- 画直线的问题
- 参数类型不正确,或不在可以接受的范围之内,或与其他的参数冲突
- 帮忙写个计算器 + - * / = 按钮的 代码
- 帮忙解释
- SSTAB控件VB中没有设置标签背景色的属性,请问如何用API设置?
- DATA控件的问题
- 用vb操作access数据库的一个问题
- 请问如何把一个数据库(表)中的所有记录添加到另一个数据库(表)中??急急急……
- 如何快速在检索结果中定位某一记录?
- 关于adodb.recordset集合能够容纳的最多记录数是多少,这个最多容纳数是否可以修改!
- 请问,我想在mshflexgrid和datagrid实现以下功能,该怎么做?
Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationname As String, ByVal _
lpKeyName As Any, ByVal lsString As Any, _
ByVal lplFilename As String) As LongPrivate Declare Function GetPrivateProfileString Lib _
"kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationname As String, ByVal _
lpKeyName As String, ByVal lpDefault As _
String, ByVal lpReturnedString As String, _
ByVal nSize As Long, ByVal lpFileName As _
String) As Long
'
'读INI文件.
'函数:GetIniStr
'参数:AppName 项目名.In_Key 键名,sFileName 文件名
'返回值:成功:对应的键值.失败或不存在:""
Public Function GetIniStr(ByVal AppName As String, ByVal In_Key As String, ByVal sFileName As String) As String
On Error GoTo GetIniStrErr
If VBA.Trim$(In_Key) = "" Then
GoTo GetIniStrErr
End If Dim GetStr As String
GetStr = VBA.String(128, 0)
GetPrivateProfileString AppName, In_Key, "", GetStr, 256, sFileName
GetStr = VBA.Replace(GetStr, VBA.Chr(0), "")
If GetStr = "" Then
GoTo GetIniStrErr
Else
GetIniStr = GetStr
GetStr = ""
End If
Exit FunctionGetIniStrErr:
Err.Clear
GetIniStr = ""
GetStr = ""
End Function'
'写INI文件.
'函数:WriteIniStr
'参数:AppName 项目名.In_Key 键名,In_Data 键值,sFileName 文件名
'返回值:成功=TRUE.失败=FALSE
Public Function WriteIniStr(ByVal AppName As String, ByVal In_Key As String, ByVal in_data As String, ByVal sFileName As String) As Boolean
On Error GoTo WriteIniStrErr
WriteIniStr = True
If VBA.Trim(in_data) = "" Or VBA.Trim(In_Key) = "" Or VBA.Trim(AppName) = "" Then
GoTo WriteIniStrErr
Else
WritePrivateProfileString AppName, In_Key, in_data, sFileName
End If
Exit Function
WriteIniStrErr:
Err.Clear
WriteIniStr = False
End Function
ini文件和inf文件一样吗?
一个设备驱动inf文件,如何执行他?一般如果执行inf文件,就可以把设备驱动装好的。
//一般如果执行inf文件,就可以把设备驱动装好的。
你的认识可能不对:)
http://tech.sina.com.cn/c/2003-05-22/19471.html
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
说明
查找与指定文件关联在一起的程序的文件名
返回值
Long,非零表示成功,零表示失败。会设置GetLastError
参数表
参数 类型及说明
hwnd Long,指定一个窗口的句柄,有时候,windows程序有必要在创建自己的主窗口前显示一个消息框
lpOperation String,指定字串“open”来打开lpFlie文档,或指定“Print”来打印它
lpFile String,想用关联程序打印或打开一个程序名或文件名
lpParameters String,如lpszFlie是可执行文件,则这个字串包含传递给执行程序的参数
lpDirectory String,想使用的完整路径
nShowCmd Long,定义了如何显示启动程序的常数值。参考ShowWindow函数的nCmdShow参数 偶也会帖了。
以下是M$的MSDN对LaunchINFSectionEx的解释:
http://msdn.microsoft.com/library/default.asp?url=/workshop/delivery/download/overview/launchinfsectionex.aspLaunchINFSectionEx Function Internet Development Index --------------------------------------------------------------------------------Launches a section of an information (INF) file.SyntaxHRESULT WINAPI LaunchINFSectionEx( HWND hwnd,
HINSTANCE hInst,
PSTR pszParams,
INT nShow
);
Parametershwnd
HWND that specifies the owner window on which to display error messages. This parameter is typically NULL, which causes the Desktop to be the owner window.
hInst
Handle to the instance of the program. This parameter is typically NULL.
pszParams
Comma-delimited string that specifies the INF file, the section of the INF file to launch, the fully qualified path of the cabinet file (CAB) that contains the INF file, and the flags that specify the installation mode, in that order. If you do not specify the fully qualified path of the INF file, the INF file is extracted from the specified CAB file. If you do not specify a section, that is, if the section portion of the pszParams string is an empty string or is set to NULL, then the DefaultInstall section of the INF file is launched. The following flags are used to specify the installation mode.
4 Quiet mode, no UI
8 Don't run GrpConv
16 Force self-updating on user's system
32 Backup data before install
64 Rollback to previous state
128 Validate the backup data
256 Complete rollback to previous state
512 Force delay of OCX registration
nShow
Variable of type INT that specifies whether to reboot the user's machine upon completion. Can be one of the following values.
A
Always reboot.
I
Default. Reboot if needed.
N
No reboot.
Return ValueReturns one of the following values.S_OK The section launched successfully.
E_FAIL The section failed to launch.
ResYou can call this function using Rundll32.exe from the command line.Note Using an entry point function with Rundll32.exe does not resemble a normal function call. The function name and the name of the .dll file where it is stored are used only as command line parameters. The function definition shown in the Syntax section of this topic is only a standard prototype for all functions that you can call using Rundll32. The specific values for hwnd and hInst are not provided by the user, but are handled behind the scenes by Rundll32.
ExamplesThe following examples demonstrate how to call the LaunchINFSectionEx function using Rundll32.
This example demonstrates how to extract the myinf.inf INF file from the c:\temp\mydata.cab CAB file in Quiet|Backup mode, and reboot if needed.rundll32.exe advpack.dll,LaunchINFSectionEx myinf.inf,,c:\temp\mydata.cab,36
This example demonstrates how to roll back to the state before the myinf.inf INF file was installed.rundll32.exe advpack.dll,LaunchINFSectionEx c:\windows\inf\myinf.inf,,,256
Function InformationStock Implementation advpack.dll
Custom Implementation No
Import library None
Minimum availability Internet Explorer 5.01
Minimum operating systems Windows 2000 See AlsoAbout INF File Architecture, Using INF Files
操作系统的最低版本是Windows 2000 ,我们98的又要干瞪眼了,郁闷!
我在运行里面执行
rundll.exe setupx.dll,InstallHinfSection DefaultInstall 132 C:\usb驱动\x.inf
没什么反应,是不是什么地方错了
大家交流一下
这个路径就是从注册表里找的,为什么不行我就不知道了。
要不试试这样的:
rundll32.exe advpack.dll,LaunchINFSectionEx c:\windows\inf\myinf.inf,,,256
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command1_Click()
Dim i As Long
i = ShellExecute(Me.hwnd, "install", "你的inf文件路径", vbNullString, vbNullString, 1)
End Sub