[wix-users] Several questions concerning WiX and the use of INI files
Hoover, Jacob
Jacob.Hoover at greenheck.com
Tue Jul 3 09:57:38 PDT 2018
This isn't a WiX limitation, but rather a windows installer limitation. https://msdn.microsoft.com/en-us/library/windows/desktop/aa369283(v=vs.85).aspx
https://blogs.msdn.microsoft.com/jschaffe/2012/10/23/creating-wix-custom-actions-in-c-and-passing-parameters/ Is a decent starter, though I wonder if you really want to make .Net a pre-req for your installer. You could write a native CA, as you are just wrapping the Win32 API...
extern "C" HRESULT ReadIni(
__in LPCWSTR wzFile,
__in LPCWSTR wzSection,
__in LPCWSTR wzKey,
__in LPWSTR* ppwzValue)
{
HRESULT hr = S_OK;
LPWSTR pwzValue = NULL;
DWORD dwLength = 0;
DWORD dwAllocatedLength = 10;
do
{
dwAllocatedLength*=2;
hr = StrAlloc(&pwzValue, dwAllocatedLength);
ExitOnFailure(hr, "Failed to allocate value buffer");
dwLength = ::GetPrivateProfileStringW(wzSection, wzKey, NULL, pwzValue, dwAllocatedLength, wzFile );
if (0 == dwLength)
{
hr = HRESULT_FROM_WIN32(GetLastError());
ExitOnFailure(hr, "failed to read ini");
}
} while(dwLength == dwAllocatedLength - 1);
hr = StrAllocConcat(ppwzValue, pwzValue, dwLength);
ExitOnFailure(hr, "Failed to copy value buffer");
LExit:
ReleaseStr(pwzValue);
return hr;
}
-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Pohan De rouen via wix-users
Sent: Tuesday, July 3, 2018 5:06 AM
To: wix-users at lists.wixtoolset.org
Cc: Pohan De rouen <pohanonche at rocketmail.com>
Subject: [wix-users] Several questions concerning WiX and the use of INI files
Hi everyone,
I'm having a hard time reading properties via an ini file in order to custom setup parameters of my MSI.Currently, I have several issues:- WiX seems to only be able to read INI files from the WindowsFolder, but I'm specifically asked to read them from the TempFolder after the user has modified it.(and the user can't write in C:\Windows\ anyway)
- .ini files I create with WiX are encoded in utf8 but here again I saw on the web that WiX is only able to read ANSI-encoded .ini files. Is there a way to ask WiX to write only in ANSI files ?- I found this : INI File Reader in C# but I have no idea how to use it as I can't find a real begginer's guide for custom actions and I don't ever know if it will solve my issues.
I am surprised to see so few topics concerning the use of INI files to read setup properties in WiX as I feel like it is a common task. I've spent several days on it already and it is really stopping me from going forward, so I will be glad if at least one of these issues could be solved!
Thanks a lot for your help!
|
| |
INI File Reader in C#
Most .NET applications do not need access to the old INI file format, so Microsoft decided not to include it in ... | |
|
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
More information about the wix-users
mailing list