Sign in to follow this  
Followers 0
shai

help with DllCall

8 posts in this topic

i try use dllcall for call MsiGetFileVersion func from msi.dll.

but i dont get it.

this is me trying code:

$a = DllCall("msi.dll","long","MsiGetFileVersion","str","c:\anymsifile.msi",Binary(1024),Binary(4),0,0)

MsgBox(0,'', $a)

 this is a article in microsoft about this function

http://msdn.microsoft.com/en-us/library/aa370122(v=vs.85).aspx

thanks for your help.

Share this post


Link to post
Share on other sites



Try specifying cdecl calling convention.  See remarks for DllCall

Share this post


Link to post
Share on other sites

cdecl?

Share this post


Link to post
Share on other sites

It's a calling convention.  If you search it and read the help you will find.

Share this post


Link to post
Share on other sites

you mean "return type"?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

i write this func for the get version of msi file:

Func get_msiversion($FilePath)
    If Not FileExists($FilePath) Then Return SetError(1, 0, 0)
    Dim $installer, $database, $view, $result
    $installer = ObjCreate("WindowsInstaller.Installer")
    $database = $installer.OpenDatabase ($FilePath, 0)
    if @error Then Return SetError(2, 0, 0)
    $view = $database.OpenView ("SELECT Value FROM Property WHERE Property='ProductVersion'")
    $view.Execute
    $result = $view.Fetch
    Return $result.StringData(1)
EndFunc

but I prefer use dllcall. sameone can help me to do this?

Edited by shai

Share this post


Link to post
Share on other sites

MsiGetFileVersion is a function that reads the version resource information from a PE file (.exe or .dll) the same way the Windows Installer does. It will not get you the version information out of an MSI. Use the MsiGetProduct... functions to get this information.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

you mean "return type"?

 

No.  Calling convention has to do with order of parameters passed to function calls.  If the calling program and called function don't use the same conventions the data passed in will be scrambled.  Also it can cause the program to crash.  For detailed explanation you should search.

Edit:  this should get you started.

http://en.wikipedia.org/wiki/Calling_convention

Edited by MilesAhead

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0