InstallShield 写注册表,如何得到程序安装路径?

时间:2022-06-01 21:21:40
用InstallShield打包程序,请问如何得到安装路径<TARGETDIR>,我想将此路径写到注册表里

11 个解决方案

#1


IS的系统变量TARGETDIR就是安装路径<TARGETDIR>

#2


//假如你要写入的项为szKey

    if RegDBKeyExist(szKey) < 0 then
     //this key not exsit ,pls create 
     RegDBCreateKeyEx(szKey,"");
    endif;
//在使用RegDBSetKeyValueEx赋Key值
RegDBSetKeyValueEx(szKey,szNumName,nType,szNumValue,nSize);

#3


可是我要在别的程序调用这个路径啊,就是installshield安装完成后

#4


你可以在is中把你的安装路径写道注册表里面,然后别的程序读这个值就可以获得了。

#5


//假如你要写入的项为szKey

    if RegDBKeyExist(szKey) < 0 then
    //this key not exsit ,pls create 
    RegDBCreateKeyEx(szKey,"");
    endif;
//在使用RegDBSetKeyValueEx赋Key值
RegDBSetKeyValueEx(szKey,szNumName,nType,szNumValue,nSize);

—————————————————————————————————————————

使用我这个方法写注册表,然后在别的程序中读取制定的存储安装路径的注册表项值,不行吗?!

#6


to winehero:
RegDBCreateKey 好像只能建在HKEY_CLASSES_ROOT下

我的安装程序注册一般都在 HKEY_LOCAL_MACHINE,可以更改注册目录吗?

#7


那就在RegDBCreateKey之前先调用 RegDBSetDefaultRoot 将当前ROOT设为 HKEY_LOCAL_MACHINE

  // Set the root key to HKEY_LOCAL_MACHINE.

   nRootKey = HKEY_LOCAL_MACHINE;

   if (RegDBSetDefaultRoot (nRootKey) < 0) then

      MessageBox ("First call to RegDBSetDefaultRoot failed.", SEVERE);

   else

      MessageBox ("Root key successfully set to HKEY_LOCAL_MACHINE.",
INFORMATION);

   endif;

#8


to winehero:

你的这段程序放在哪里比较好? 我是第一次用InstallShield,很多不懂,让各位大侠见笑了

#9


我是这么写的,在OnFirstUiBefore 的end前加入这段程序(szKey和nRootKey已定义):

nRootKey = HKEY_LOCAL_MACHINE;

    if (RegDBSetDefaultRoot (nRootKey) < 0) then

       MessageBox ("First call to RegDBSetDefaultRoot failed.", SEVERE);

    else

       MessageBox ("Root key successfully set to HKEY_LOCAL_MACHINE.",INFORMATION);

    endif;
      
szKey="SOFTWARE\\DCH\\DS";
if RegDBKeyExist(szKey) < 0 then
    RegDBCreateKeyEx(szKey,"");
         endif;         
         RegDBSetKeyValueEx(szKey,"InstallPath",REGDB_STRING,TARGETDIR,-1);

好像不行啊,我再查查

#10


在OnFirstUIAfter中写吧。。。
因为在OnFirstUiBefore中写的话,在用户选取安装目录前执行这段的话,这时的TARGETDIR显然就不是
TARGETDIR,选取目录后记得更改TARGETDIR。

你写的脚本其它部分应该问题不大。。。

#11


ok,总算搞定了,原来要自己写 OnFirstUIAfter 这个过程,InstallShield不会自动生成,谢谢winehero

#1


IS的系统变量TARGETDIR就是安装路径<TARGETDIR>

#2


//假如你要写入的项为szKey

    if RegDBKeyExist(szKey) < 0 then
     //this key not exsit ,pls create 
     RegDBCreateKeyEx(szKey,"");
    endif;
//在使用RegDBSetKeyValueEx赋Key值
RegDBSetKeyValueEx(szKey,szNumName,nType,szNumValue,nSize);

#3


可是我要在别的程序调用这个路径啊,就是installshield安装完成后

#4


你可以在is中把你的安装路径写道注册表里面,然后别的程序读这个值就可以获得了。

#5


//假如你要写入的项为szKey

    if RegDBKeyExist(szKey) < 0 then
    //this key not exsit ,pls create 
    RegDBCreateKeyEx(szKey,"");
    endif;
//在使用RegDBSetKeyValueEx赋Key值
RegDBSetKeyValueEx(szKey,szNumName,nType,szNumValue,nSize);

—————————————————————————————————————————

使用我这个方法写注册表,然后在别的程序中读取制定的存储安装路径的注册表项值,不行吗?!

#6


to winehero:
RegDBCreateKey 好像只能建在HKEY_CLASSES_ROOT下

我的安装程序注册一般都在 HKEY_LOCAL_MACHINE,可以更改注册目录吗?

#7


那就在RegDBCreateKey之前先调用 RegDBSetDefaultRoot 将当前ROOT设为 HKEY_LOCAL_MACHINE

  // Set the root key to HKEY_LOCAL_MACHINE.

   nRootKey = HKEY_LOCAL_MACHINE;

   if (RegDBSetDefaultRoot (nRootKey) < 0) then

      MessageBox ("First call to RegDBSetDefaultRoot failed.", SEVERE);

   else

      MessageBox ("Root key successfully set to HKEY_LOCAL_MACHINE.",
INFORMATION);

   endif;

#8


to winehero:

你的这段程序放在哪里比较好? 我是第一次用InstallShield,很多不懂,让各位大侠见笑了

#9


我是这么写的,在OnFirstUiBefore 的end前加入这段程序(szKey和nRootKey已定义):

nRootKey = HKEY_LOCAL_MACHINE;

    if (RegDBSetDefaultRoot (nRootKey) < 0) then

       MessageBox ("First call to RegDBSetDefaultRoot failed.", SEVERE);

    else

       MessageBox ("Root key successfully set to HKEY_LOCAL_MACHINE.",INFORMATION);

    endif;
      
szKey="SOFTWARE\\DCH\\DS";
if RegDBKeyExist(szKey) < 0 then
    RegDBCreateKeyEx(szKey,"");
         endif;         
         RegDBSetKeyValueEx(szKey,"InstallPath",REGDB_STRING,TARGETDIR,-1);

好像不行啊,我再查查

#10


在OnFirstUIAfter中写吧。。。
因为在OnFirstUiBefore中写的话,在用户选取安装目录前执行这段的话,这时的TARGETDIR显然就不是
TARGETDIR,选取目录后记得更改TARGETDIR。

你写的脚本其它部分应该问题不大。。。

#11


ok,总算搞定了,原来要自己写 OnFirstUIAfter 这个过程,InstallShield不会自动生成,谢谢winehero