NULL as parameter for a dll function call

Got a problem you cannot solve? Try here.
paulga
Posts: 17
Joined: Thu Aug 10, 2006 6:50 am
Location: England

NULL as parameter for a dll function call

Postby paulga » Tue Jan 02, 2007 10:06 am

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

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Wed Jan 03, 2007 9:53 am

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.
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/

paulga
Posts: 17
Joined: Thu Aug 10, 2006 6:50 am
Location: England

Postby paulga » Thu Jan 04, 2007 11:07 am

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

Tiago
Posts: 129
Joined: Thu Jun 18, 2009 9:08 am

Re: NULL as parameter for a dll function call

Postby Tiago » Mon Jul 26, 2010 12:47 pm

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! :)
Tiago Rocha
Product Technology
www.ppi-multitask.com.br

Roostar2004
Posts: 155
Joined: Mon Nov 12, 2007 11:59 am

Re: NULL as parameter for a dll function call

Postby Roostar2004 » Tue Nov 16, 2010 10:17 pm

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.

Tiago
Posts: 129
Joined: Thu Jun 18, 2009 9:08 am

Re: NULL as parameter for a dll function call

Postby Tiago » Wed Nov 17, 2010 6:16 am

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... :?
Tiago Rocha

Product Technology

www.ppi-multitask.com.br

mills
Posts: 814
Joined: Tue Jul 06, 2010 7:10 pm
Location: Honolulu, HI

Re: NULL as parameter for a dll function call

Postby mills » Wed Nov 24, 2010 3:29 pm

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~
Andy Mills
InstallAware
Other Help:
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help - Press F1 in the InstallAware IDE.


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 63 guests