Jump to content

Help with DLLCALL


Recommended Posts

; + 2 is useless I believe but anyway, just for sure.
Dim $sDirectory = 'Directory'
Dim $sPlayer = 'Player1'

Dim $tDirectory = DllStructCreate('wchar[' & StringLen($sDirectory) + 2 & ']')
                  DllStructSetData($tDirectory, 1, $sDirectory)
                  
Dim $tPlayer = DllStructCreate('wchar[' & StringLeft($sPlayer) + 2 & ']')
               DllStructSetData($tPlayer, 1, $sPlayer)
               
Dim $Ret = DllCall('OmPlr.dll', 'ptr', 'OmPlrOpen', 'wchar', DllStructGetData($tDirectory, 1), _
                   'wchar', DllStructGetData($tPlayer, 1), 'ptr', $pPlayerHandle)

That is how it should be if the *pPlayerHandle and the return value are truly handles.

Link to comment
Share on other sites

What have you tried?

$PlayerHandle = DllCall("omplrlib.dll", "int", "OmPlrOpen", "some_ip","some_name") - returns 0

and

$PlayerHandle = DllCall("omplrlib.dll", "int", "OmPlrOpen", "some_ip","some_name","hwnd" ,$hwnd) - returns 0

thanks

Link to comment
Share on other sites

to pass a wchar*, just use

"wstr", "The string" :P

to get the handle: use "ptr*" as param, 0 as value.

-> It is the third parameter, so the result will be in $ret[3]

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

; + 2 is useless I believe but anyway, just for sure.
Dim $sDirectory = 'Directory'
Dim $sPlayer = 'Player1'

Dim $tDirectory = DllStructCreate('wchar[' & StringLen($sDirectory) + 2 & ']')
                  DllStructSetData($tDirectory, 1, $sDirectory)
                  
Dim $tPlayer = DllStructCreate('wchar[' & StringLeft($sPlayer) + 2 & ']')
               DllStructSetData($tPlayer, 1, $sPlayer)
               
Dim $Ret = DllCall('OmPlr.dll', 'ptr', 'OmPlrOpen', 'wchar', DllStructGetData($tDirectory, 1), _
                   'wchar', DllStructGetData($tPlayer, 1), 'ptr', $pPlayerHandle)

That is how it should be if the *pPlayerHandle and the return value are truly handles.

Still getting "0". what am i doing wrong?

dim $pPlayerHandle

Dim $sDirectory = 'IP'
Dim $sPlayer = 'Name'

Dim $tDirectory = DllStructCreate('wchar[' & StringLen($sDirectory) & ']')
                  DllStructSetData($tDirectory, 1, $sDirectory)
                  
Dim $tPlayer = DllStructCreate('wchar[' & StringLen($sPlayer) & ']')
               DllStructSetData($tPlayer, 1, $sPlayer)
              
Dim $Ret = DllCall('omplrlib.dll', 'ptr', 'OmPlrOpen', 'wchar', DllStructGetData($tDirectory, 1), _
                   'wchar', DllStructGetData($tPlayer, 1), 'ptr', $pPlayerHandle)
                   
MsgBox(0,"Show Handle" ,$pPlayerHandle)
Link to comment
Share on other sites

to pass a wchar*, just use

"wstr", "The string" :P

to get the handle: use "ptr*" as param, 0 as value.

-> It is the third parameter, so the result will be in $ret[3]

Like this? - ($PlayerHandle = DllCall("omplrlib.dll", "ptr*", "OmPlrOpen","ip","name").

can you please add an example?

Thanks again.

Link to comment
Share on other sites

Dim $Ret = DllCall('OmPlr.dll', 'ptr*', 'OmPlrOpen', 'wstr', "DirectoryName", _
                   'wstr', "PlayerName", 'ptr*', $pPlayerHandle)

If there was no error during the call then $Ret[0] is the returned pointer and $Ret[3] is the pointer you've passed as the third parameter.

Edited by Authenticity
Link to comment
Share on other sites

Oh sorry, correct, it returns int...

So it would be (wstr for unicode):

$aCall = DllCall("OmPlr.dll", "dword", "OmPlrOpen", _
        "str", $sDirectoryName, _
        "str", $sPlayerName, _
        "ptr*", 0)

If @error Or $aCall[0] Then
    ;Return SetError(1, 0, 0) ; failure
EndIf

$hPlayer = $aCall[3]

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

So it would be (wstr for unicode):

$aCall = DllCall("OmPlr.dll", "dword", "OmPlrOpen", _
        "str", $sDirectoryName, _
        "str", $sPlayerName, _
        "ptr*", 0)

If @error Or $aCall[0] Then
    ;Return SetError(1, 0, 0) ; failure
EndIf

$hPlayer = $aCall[3]
Thank you all for your help.

when I'm running the example above autoit is crashing

and console says :

>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "D:\Desktop\Lior Bkp\Tools\DaletPlus\AU3 Scripts\OmniTest\Main.au3"

!>16:01:33 AutoIT3.exe ended.rc:-1073741819

+>16:01:34 AutoIt3Wrapper Finished

>Exit code: -1073741819 Time: 3.391

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...