开发者

how can get the path from installer and how set in my app?

开发者 https://www.devze.com 2023-02-15 09:52 出处:网络
i am writing a win app and now i want to make setup for my app,my code is: Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@\"SOFTWARE\\Microsoft\\Windows\\Cu­rrent

i am writing a win app and now i want to make setup for my app,my code is:

Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\Cu­rrentVersion\Run");
 rk.SetValue("MyAppName", @"C:\WhereMyAppIs\MyApp.exe");

now how can get the path from installer to set i开发者_Go百科t??? thanks.


If you use Visual Studio, you can right click on the setup project -> View -> Registry and then set the registry key you like.

Check out this sites:

msi - Set InstallPath registry key

Registry Settings Management (MSDN)


If it was installed using Windows Installer (.MSI files), you can use the MsiGetComponentPath API:

    [DllImport("msi.dll", CharSet = CharSet.Unicode)]
    private static extern int MsiGetComponentPath(string szProduct, string szComponent, StringBuilder lpPathBuf, ref int pcchBuf);

Call it like this:

int len = 256;
StringBuilder sb = new StringBuilder(len);
MsiGetComponentPath(productCode, componentId, sb, ref len);
0

精彩评论

暂无评论...
验证码 换一张
取 消