Your call to fopen_s uses the uninitialised cchIniName buffer as the path name to open for writing.
(BTW, misuse of Hungarian notation because this is _not_ a Count of Characters - use sz or psz for string-terminated-with-zero. If that's what you intended, of course.) You can also edit INI files using the <IniFile> element which maps to a native Windows Installer feature. The type of the Value field is Formatted, so you should be able to substitute property values using [] within the field data. -- Mike Dimmick -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julie Campbell Sent: 24 April 2007 21:09 To: 'Mike Dimmick'; wix-users@lists.sourceforge.net Subject: Re: [WiX-users] Custom Action works under WinXP-SP2,fails under Win2K? fprintf writes to the file pointed to by cchIniName. Julie Campbell [EMAIL PROTECTED] -----Original Message----- From: Mike Dimmick [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 24, 2007 4:05 PM To: 'Julie Campbell'; wix-users@lists.sourceforge.net Subject: RE: [WiX-users] Custom Action works under WinXP-SP2, fails under Win2K? Did you miss a line out? You don't appear to have written to the buffer pointed to by cchIniName so it will be filled with garbage. The success or failure may depend on whether the junk in the buffer parses as a valid file name or not. I would strongly recommend using Unicode file name buffers and therefore _wfopen_s if you're targetting Windows NT-based operating systems only and not supporting Windows 9X. -- Mike Dimmick -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Julie Campbell Sent: 24 April 2007 20:43 To: wix-users@lists.sourceforge.net Subject: [WiX-users] Custom Action works under WinXP-SP2, fails under Win2K? My installer needs to work under WinXP and Win2K for this round. I wrote a custom action and it works great under WinXP but fails under Win2K and I cannot figure out why. I am using WiX v3.0.2420, both machines have Windows R Installer. V 3.01.4000.1823 installed. The custom action is in a C++ DLL, here is the action function: UINT __stdcall WriteTSBIni(MSIHANDLE hInstaller) { UINT rc = ERROR_SUCCESS; USES_CONVERSION; // Get the installation directory name TCHAR *cchWindowsFolder = privMsiGetPropertyStr(hInstaller, TEXT("WindowsFolder")); TCHAR *cchInstallDir = privMsiGetPropertyStr(hInstaller, TEXT("INSTALLDIR")); TCHAR *cchIviDir = privMsiGetPropertyStr(hInstaller, TEXT("IVIDIRPROP")); if (cchIviDir) { if (cchWindowsFolder) { if (cchInstallDir) { size_t szBuf = strlen(W2CA(cchInstallDir)) + strlen ("Test Script Builder\\TestScriptBuilder.ini") + 1; char *cchIniName = new char[szBuf]; FILE *fIni; if (errno_t err = fopen_s(&fIni, cchIniName, "w")) { sprintf_s(cchIniName, szBuf, "err=%d", err); return ERROR_INSTALL_FAILURE; } else { fprintf (fIni, "-vmargs\r\n"); fprintf (fIni, "-Djava.lang.path=.;"); fprintf (fIni, "%s.;", W2A(cchIviDir)); fprintf (fIni, "%s.;", W2A(cchWindowsFolder)); fprintf (fIni, "%sSystem32\\.;\r\n", W2A(cchWindowsFolder)); fclose (fIni); } delete[] cchIniName; delete[] cchInstallDir; } delete[] cchWindowsFolder; } delete[] cchIviDir } return ERROR_SUCCESS; } --- The .wxs source snippet is: <CustomAction Id="CAKE_WRITE_TSB_INI" BinaryKey="CAKE_ACTIONS" DllEntry="WriteTSBIni" Return="check" /> <InstallExecuteSequence> <Custom Action="CAKE_WRITE_TSB_INI" After='CreateShortcuts'>NOT Installed</Custom> </InstallExecuteSequence> --- I ran with the /la switch and got the same sequence on both machines, until after the CAKE_WRITE_TSB_INI action. I checked the sequencing with Orca, CAKE_WRITE_TSB_INI is in the InstallExecuteSequence table at #4501, right after CreateShortcuts as expected. The fopen_s error that I get under Win2K indicates the folder doesn't exist (2). I used message boxes to pause the custom action and checked, and despite being past that point in the log file and sequence, the directory indeed was non-existent. I have no idea what to try next or why this is behaving differently. Help? Julie Campbell [EMAIL PROTECTED] ____________________________________________________________________________ _ Scanned by IBM Email Security Management Services powered by MessageLabs. For more information please visit http://www.ers.ibm.com ____________________________________________________________________________ _ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ____________________________________________________________________________ _ Scanned by IBM Email Security Management Services powered by MessageLabs. For more information please visit http://www.ers.ibm.com ____________________________________________________________________________ _ ____________________________________________________________________________ _ Scanned by IBM Email Security Management Services powered by MessageLabs. For more information please visit http://www.ers.ibm.com ____________________________________________________________________________ _ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users