cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DanCla
Level 5

Can't find file in SUPPORTDIR

I placed my file in support files / language independent. When I run the code below in a custom action I get my FindFile failed message box. Can anybody tell me what I am doing wrong?

#include "ifx.h"
export prototype MyFunction(HWND);
function MyFunction(hMSI)
STRING DllPath, svResult;
begin
DllPath = SUPPORTDIR^"CustomActionLibrary.dll";
MessageBox("Path to DLL: " + DllPath, INFORMATION);
if (FindFile(SUPPORTDIR, "CustomActionLibrary.dll", svResult) < 0) then
MessageBox ("FindFile failed.", SEVERE);
else
SprintfBox (INFORMATION, "FindFile Example", "Found: %s in %s.", svResult, SUPPORTDIR);
endif;
end;
Labels (1)
0 Kudos
(5) Replies
RobertDickau
Flexera Alumni

What type of project? You might try getting the value of the SUPPORTDIR property (using MsiGetProperty) instead of the SUPPORTDIR variable.
0 Kudos
DanCla
Level 5

I am trying to implement this in a basic msi project. I changed my code to use MsiGetProperty and still get FindFile Failed. At runtime the file gets placed in a different temp directory than the one pointed to by SUPPORTDIR. The changes I made are shown below.

#include "ifx.h"
export prototype MyFunction(HWND);
function MyFunction(hMSI)
STRING DllPath, ClassName, Domain, supportDirPath;
STRING svToDll, svFromDll, svResult;
NUMBER nvSize;
OBJECT DotNetObj;
begin
nvSize = 256;
MsiGetProperty(hMSI, "SUPPORTDIR", supportDirPath, nvSize);
DllPath = supportDirPath^"CustomActionLibrary.dll";
MessageBox("Path to DLL: " + DllPath, INFORMATION);
if (FindFile(SUPPORTDIR, "CustomActionLibrary.dll", svResult) < 0) then
MessageBox ("FindFile failed.", SEVERE);
else
SprintfBox (INFORMATION, "FindFile Example", "Found: %s in %s.", svResult, SUPPORTDIR);
endif;
end;
0 Kudos
dan_galender
Level 10

Even though you retrieved the value of the SUPPORTDIR property, you used the SUPORTDIR variable in your FindFile call. Try changing the if statement from:

if (FindFile(SUPPORTDIR, "CustomActionLibrary.dll", svResult) < 0) then

to:

if (FindFile(supportDirPath, "CustomActionLibrary.dll", svResult) < 0) then


and see if that works better.
0 Kudos
DanCla
Level 5

Thank you DanGalender, I knew that... That's what I get for trying to code before having coffee in the morning. So I made that change and it worked, is there a reason why just using SUPPORTDIR does not work?
0 Kudos
RobertDickau
Flexera Alumni

The notes in the InstallShield help topic "SUPPORTDIR" have a bit more information about it.
0 Kudos