Page 1 of 1

NULL as parameter for a dll function call

Posted: Tue Jan 02, 2007 10:06 am
by paulga
Hi,

to get over the problem of msi installs requiring the original media on an uninstall I'm using CopyFileA to copy files and MoveFileEx to remove files, both from kernel32.dll.

CopyFileA seems to work correctly but I'm having problems getting MoveFileEx to work.

If I use the follwing with c++ :

MoveFileEx(directory + "\\\\" + filename, NULL ,MOVEFILE_DELAY_UNTIL_REBOOT)

everything works fine however when calling it from the install script it looks as though for some reason it doesn't like '0' or 'NULL' as the second parameter, I can see this from what it puts in the registry, it creates a multi string, for each entry the 1st line is the original file inc path and the second line should be NULL, calling it from the install script it's trying to put a path in for the second line and as a result the files aren't removed on a reboot.

Has anyone had any success using this function or know why it might not like the second parameter?

Thanks

Paul

Posted: Wed Jan 03, 2007 9:53 am
by MichaelNesmith
I'd try the following values to represent NULL:

double word, 0 (zero)
pointer to string, empty string
allocated string buffer, script variable that is set to an empty string

Let me know if none of these work.

Posted: Thu Jan 04, 2007 11:07 am
by paulga
Hi Michael,

just to let you know that none of these worked as nothing went into the registry, the function does expect a pointer to a string. Have you any other ideas.

Thanks

Paul

Re: NULL as parameter for a dll function call

Posted: Mon Jul 26, 2010 12:47 pm
by Tiago
Hi there.

I'm using the Call DLL function to execute the CreateFile Windows API function (from Kernel32.dll) to retrieve the HANDLE for a specific file.
MSDN documentation (http://msdn.microsoft.com/en-us/library ... 85%29.aspx) says I have to pass 7 parameters:
__in LPCTSTR lpFileName,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
__in DWORD dwCreationDisposition,
__in DWORD dwFlagsAndAttributes,
__in_opt HANDLE hTemplateFile


The third parameter is an optional structure and since I'm supposing IA9 Call DLL Plugin does not support structure pointers, I'm passing an empty Allocated String Buffer, but the plugin is returning EXTERNALEXCEPTION.

Code: Select all

~InstallAware Clipboard Data~
~Call DLL Function~
~{D55CB94D-5AA7-4066-806F-76E16F4EBEE4}~
~Kernel32.dll,CreateFile,"double word",FILE_HANDLE,"pointer to string",D:\Pacote\CompBin\PCF_DCMServer.exe,"double word",8,"double word",1,"allocated string buffer (MAX_PATH length)",,"double word",3,"double word",128,$~
~mIDEFunc.dll\mEXEFunc.dll~
~Set Variable~
~{2EB18E33-0BE7-4DE0-8F99-500D30204322}~
~FILE_HANDLE$MYAH$MYAH$FALSE~
~~


Am I doing something wrong on this one?
Thanks in advance! :)

Re: NULL as parameter for a dll function call

Posted: Tue Nov 16, 2010 10:17 pm
by Roostar2004
Tiago,
I am running into the same issue and was wondering if you have figured out how to get the CreateFile function to run? If you did I would like to see the code you are passing in.

Re: NULL as parameter for a dll function call

Posted: Wed Nov 17, 2010 6:16 am
by Tiago
Hi, Roostar2004.

Not really. I'm avoiding at all costs this kind of API with complex parameters in MSICode. When I really have to, I write an external application to do the dirty work. I was hoping someone from IA team would shed some light on this topic, but still we haven't got a reply.

I am sorry... :?

Re: NULL as parameter for a dll function call

Posted: Wed Nov 24, 2010 3:29 pm
by mills
Make sure you're passing valid arguments for the rest of the besides what you want NULL as well.

I was able to create a file with this:

Code: Select all

~InstallAware Clipboard Data~
~Call DLL Function~
~{6F6985E4-0F18-427C-8E0A-82114735C5AD}~
~Kernel32.dll,CreateFile,"double word",FILE_HANDLE,"pointer to string",C:\PCF_DCMServer.txt,"double word","GENERIC_READ | GENERIC_WRITE","double word",0,long,NULL,"double word",1,"double word",128,long,NULL,$~
~mIDEFunc.dll\mEXEFunc.dll~