"SystemFolder" in WIX and C#
Asked Answered
T

1

12

An installer I have created with WiX installs a DLL using the SystemFolder variable, as well as a C# app into another folder. I want to directly reference the DLL from the app. Do I need to look up registry keys to find where the SystemFolder is?

Tremann answered 30/3, 2012 at 9:55 Comment(0)
P
16

No, you don't need to query the registry. Windows Installer has a series of built-in properties that automatically resolve to special well known locations such as SystemFolder.

See System Folder Properties for more general information. For WiX, just create a Directory element as a direct child of the TARGETDIR Directory element:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="SystemFolder" Name="SystemFolder" />
</Directory>

If you already know this and want to know how to reference the DLL from C#, SystemFolder is in the search path so I'm not sure why you'd have to. If it was me, I'd compile the C# as x86 ( AnyCPU is somewhat out of vogue now ) and use:

string myDllPath = Path.Combine( System.Environment.SystemDirectory, "my.dll" );
Postman answered 30/3, 2012 at 10:43 Comment(1)
Note: On 64-bit Windows SystemFolder points to the 32-bit system directory: C:\WINDOWS\SysWOW64\, while System64Folder points to the 64-bit folder: C:\WINDOWS\system32\ (and System64Folder is not set on a 32-bit system). To my knowledge there is no property which always points to the native system folder.Roby

© 2022 - 2024 — McMap. All rights reserved.