Jump to content

Yet another DllCall() problem


Recommended Posts

;) Hello everyone. Yet I face another DllCall (maybe DllStruct?) problem here, could someone please guide me, here's the code:

#include 
Global Const $hDllBthProps = DllOpen("bthprops.cpl")

Func _BluetoothFindFirstDevice()
$tBLUETOOTH_DEVICE_SEARCH_PARAMS = DllStructCreate('DWORD;BOOL;BOOL;BOOL;BOOL;BOOL;BYTE;HANDLE')
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 1 , DllStructGetSize($tBLUETOOTH_DEVICE_SEARCH_PARAMS))
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 2 , False)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 3 , False)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 4 , True)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 5 , False)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 6 , True)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 7 , 30)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 8 , Null)
$SYSTEMTIME=DllStructCreate("ushort wYear;ushort wMonth;ushort wDayOfWeek;ushort wDay;ushort wHour;ushort wMinute;ushort wSecond;ushort wMilliseconds")
DllCall("Kernel32.dll","none","GetSystemTime","ptr",DllStructGetPtr($SYSTEMTIME))
$tBLUETOOTH_DEVICE_INFO = DllStructCreate('DWORD;ULONG;ULONG;BOOL;BOOL;BOOL;ptr;ptr;WCHAR')
DllStructSetData($tBLUETOOTH_DEVICE_INFO,1,DllStructGetSize($tBLUETOOTH_DEVICE_INFO))
DllStructSetData($tBLUETOOTH_DEVICE_INFO,7,DllStructGetPtr($SYSTEMTIME))
DllStructSetData($tBLUETOOTH_DEVICE_INFO,8,DllStructGetPtr($SYSTEMTIME))
$RESULT = DllCall($hDllBthProps, "handle", "BluetoothFindFirstDevice", "struct*", $tBLUETOOTH_DEVICE_SEARCH_PARAMS, "struct*", $tBLUETOOTH_DEVICE_INFO)
msgbox(64, "", 'Result: ' & $RESULT[0] & @crlf & 'WinAPI Error: ' & _WinAPI_GetLastErrorMessage() & @crlf & 'Error: ' & @error)
EndFunc

_BluetoothFindFirstDevice()

The function doesn't seem to work, even though I have enabled and paired up my laptop and computer's bluetooth. :)

Thanks.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

JohnOne JohnOne JohnOne, bthprops.cpl is itself a dll that can be 'executed' by rundll32.exe, I indeed tried calling the DLL but couldn't. If you see my signature for Bluetooth Detector Script, you will find that I am indeed right in my approach.

MKISH.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

try to change the BLUETOOTH_DEVICE_INFO structure...

#include

Global Const $hDllBthProps = DllOpen("bthprops.cpl")



Func _BluetoothFindFirstDevice()
$tBLUETOOTH_DEVICE_SEARCH_PARAMS = DllStructCreate('DWORD;BOOL;BOOL;BOOL;BOOL;BOOL;BYTE;HANDLE')
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 1 , DllStructGetSize($tBLUETOOTH_DEVICE_SEARCH_PARAMS))
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 2 , False)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 3 , False)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 4 , True)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 5 , False)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 6 , True)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 7 , 30)
DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 8 , 0)
;$SYSTEMTIME=DllStructCreate("ushort wYear;ushort wMonth;ushort wDayOfWeek;ushort wDay;ushort wHour;ushort wMinute;ushort wSecond;ushort wMilliseconds")
;DllCall("Kernel32.dll","none","GetSystemTime","ptr",DllStructGetPtr($SYSTEMTIME))
$tBLUETOOTH_DEVICE_INFO = DllStructCreate('DWORD;UINT64;ULONG;BOOL;BOOL;BOOL;word[8];word[8];WCHAR[248]')
DllStructSetData($tBLUETOOTH_DEVICE_INFO,1,DllStructGetSize($tBLUETOOTH_DEVICE_INFO))
;DllStructSetData($tBLUETOOTH_DEVICE_INFO,7,DllStructGetPtr($SYSTEMTIME))
;DllStructSetData($tBLUETOOTH_DEVICE_INFO,8,DllStructGetPtr($SYSTEMTIME))
$RESULT = DllCall($hDllBthProps, "handle", "BluetoothFindFirstDevice", "struct*", $tBLUETOOTH_DEVICE_SEARCH_PARAMS, "struct*", $tBLUETOOTH_DEVICE_INFO)
msgbox(64, "", 'Result: ' & $RESULT[0] & @crlf & 'WinAPI Error: ' & _WinAPI_GetLastErrorMessage() & @crlf & 'Error: ' & @error)
EndFunc

_BluetoothFindFirstDevice()
Link to comment
Share on other sites

Hats off to j0linus... thanks man, you saved the day.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

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

×
×
  • Create New...