首页  编辑  

INF的安装和卸载

Tags: /超级猛料/Registry.注册表和INI/   Date Created:

Inf是一个类似INI的文件,比小小巧绿色,非常方便的一种安装方式!如果程序中要调用INF来安装和卸载,可以这样:

格式如下:

RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection <section><mode><path>

Path指定了安装和调用那个INF文件。

section为INF中某一个小节的名字!

mode可以为以下的几个值或组合:

Value Description

0 System provided INF.

128 Set the default path of the installation to the location of the INF. This is the typical setting.

+0 Never reboot the computer.

+1 Reboot the computer in all cases.

+2 Always ask the users if they want to reboot.

+3 Reboot the computer if necessary without asking user for permission.

+4 If a reboot of the computer is necessary, ask the user for permission before rebooting.

下面是安装和卸载的两个例子:

安装:

rundll32 setupapi.dll,InstallHinfSection DefaultInstall 128 .\right.inf

卸载:

rundll32 setupapi.dll,InstallHinfSection DefaultUnInstall 128 .\right.inf

当然你也可以按API方式调用!

VOID CALLBACK InstallHinfSection(

 HWND hwnd,

 HINSTANCE ModuleHandle,

 PCTSTR CmdLineBuffer,

 INT nCmdShow

);

Parameters

hwnd

[in] The parent window handle. Typically hwnd is Null.

ModuleHandle

[in] Reserved and should be Null.

CmdLineBuffer

[in] Pointer to buffer containing the command line. You should use a null-terminated string.

nCmdShow

[in] Reserved and should be zero.

Return Values

This function does not return a value.