Jump to content

Recommended Posts

Posted

Hello all,

thanks for reading, i need to execute a DLLCALL but i cannot figure out how too translate it to autoit (Func Description is attached).

Thanks in advance.

Func.txt

Posted

; + 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.

Posted

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

Posted

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

Posted

; + 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)
Posted (edited)

Use what ProgAndy suggested. use 'ptr*' as the parameter and return type.

Edit: Also, my mistake, don't send it using wchar param. Use wstr instead.

Edited by Authenticity
Posted

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.

Posted (edited)

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
Posted

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

Posted

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

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
×
×
  • Create New...