Jump to content

Using Dllcall And Vb6


Recommended Posts

Ok im quite new to this dono alot about vb6 but i wanna learn how this stuff works with autoit.

Hahaha 4got my ?

anyways how would i do simple programs say a hello program?

Edited by kcd-clan
Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()
Link to comment
Share on other sites

Fo som searching for dll and dev-c.

Also remember that vb6 does make com dll's so you have to use the com API in AutoIt.

Link to comment
Share on other sites

My first attempts :

[OT]

some experiment with :

Shell.Application WScript.Shell :

;$s_URL="www.google.it"
$s_URL="c:\test.txt"

;DllCall("Shell32.dll","int","ShellExecute","hwnd",0,"str",'open',"str",$s_URL,"str",'',"str",@WorkingDir, "int", 10)

#cs
;Shell.applicarion
$s_URL2="c:\test"
$o_SA = ObjCreate("Shell.Application")
$o_SA.Open(0) ;desktop folder
$o_SA.ControlPanelItem( "desk.cpl")
$o_SA.ControlPanelItem("Inetcpl.cpl")
$o_SA.ControlPanelItem(" Modem.cpl")
$o_SA.MinimizeAll
;$o_SA.UndoMinimizeALL
#ce

; WScript.Shell useful for run command
$o_SW = ObjCreate("WScript.Shell")
$o_SW.run("c:\test.txt")

$o_SW = ObjCreate("WScript.Shell")
;Set oShell = WScript.CreateObject("WScript.Shell")
$r = $o_SW.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir")
MsgBox(262144, "", $r)

#cs
$o_SW = ObjCreate("WScript.Shell")
$o_SW.run("C:\WINDOWS\EXPLORER.EXE ::"& _
"{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::"& _
"{992CFFA0-F557-101A-88EC-00DD010CCC48}"),3
#ce
Link to comment
Share on other sites

My first attempts :

DllCall("Shell32.dll", "int", "ShellExecute", "hwnd", 0, "str", 'open', "str","c:\windows\calc.exe", "str", '', "str", @WorkingDir, "int", 10)
sleep(500)
DllCall("Shell32.dll", "int", "ShellExecute", "hwnd", 0, "str", 'open', "str","c:\windows\notepad.exe", "str", '', "str", @WorkingDir, "int", 10)
;Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
$r = DllCall('kernel32','long','GetTickCount')
;MsgBox(4096,'Time','Windows started ' & $r[0] & ' ms ago.')

;Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, 
;ByVal lpWindowName As String) As Long
Sleep(500)
$hwnd  = DllCall("user32.dll","long","FindWindow","str","Notepad","str","Untitled - Notepad")
$hwndCalc = DllCall("user32.dll","long","FindWindow","str","SciCalc","str","Calculator")
;MsgBox(262144, "",@error )
MsgBox(262144, "","Notepad hwnd  " & $hwnd[0])
MsgBox(262144, "", "Calc hwnd  "&$hwndCalc[0])

;Declare Function ShowWindow Lib "user32" Alias "ShowWindow" 
;(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
;Global Const $SW_SHOWNORMAL = 5
;$call =DllCall ( "user32.dll", "long", "ShowWindow " , "hwnd", $hwndCalc[0] , "long", 5 )
;MsgBox(262144, "",@error )
;MsgBox(262144, "",$call )

;;;;;;;$hwnd = WinGetHandle("Untitled - Notepad")
;;;;;;;$hwndCalc = WinGetHandle("Calculator")


; Declare Function SetForegroundWindow Lib "user32" Alias 
;"SetForegroundWindow" (ByVal hwnd As Long) As Long
 $goal = DLLCall("user32.dll","long","SetForegroundWindow","hwnd",$hwnd[0])
; MsgBox(262144, "", "Error  " &@error )
 ; MsgBox(262144, "",$goal)
sleep(3000)
 $goal = DLLCall("user32.dll","long","SetForegroundWindow","hwnd", $hwndCalc[0])

;MsgBox(262144, "", "Error  " &@error )
 ; MsgBox(262144, "",$goal)


#cs
Dynamically calls a function in a DLL.
DllCall ( "dll", "return type", "function" [, "type1", param1 [, "type n", param n]] )


originale apiguide
Declare Function FlashWindow Lib "user32" Alias "FlashWindow" 
(ByVal hwnd As Long, ByVal bInvert As Long) As Long
#ce
$goal = DLLCall("user32.dll","long","SetForegroundWindow","hwnd", $hwndCalc[0])
sleep(2000)
$goal = DLLCall("user32.dll","long","SetForegroundWindow","hwnd",$hwnd[0])
;;;;;;;While 1  buono anche questo
For $i = 1 to 20
$f = DllCall("user32","int","FlashWindow","hwnd",$hwnd[0],"int",1)
sleep(100)
;msgbox(0, "", $f) 
Next

$goal = DLLCall("user32.dll","long","SetForegroundWindow","hwnd", $hwndCalc[0])
sleep(2000)
For $i = 1 to 20
$f = DllCall("user32","int","FlashWindow","hwnd",$hwndCalc[0],"int",1)
sleep(100)
Next

; $hwnd3 = DLLCall("user32.dll","int","FindWindowEx","int",$hwnd2[0] ,"str","","hwnd","Edit")
$hwnd3 = DLLCall("user32.dll","long","FindWindowEx","hwnd",$hwnd[0] ,"int","0","int","","int","")
  
  MsgBox(262144, "", $hwnd3[0])
;MsgBox(262144, "", $hwnd3[1])
 
 $dec = StringRight ($hwnd3[1],"8" )
$dec2 = Dec($dec)
msgbox(0, "","Notepad's Edit hwnd  "& $dec2)



;;;;;;wend
#cs
originale api guide
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, 
ByVal lpString As String, ByVal cch As Long) As Long
#ce
$goal = DLLCall("user32.dll","long","SetForegroundWindow","hwnd",$hwnd[0])
sleep(100)
$result = DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hwnd[0], "str", "", "int", 32768)
msgbox(0, "", $result[0]) ; number of chars returned

msgbox(0, "", $result[2]) ; Text returned in param 2

;Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long
;$resultx = DllCall("user32.dll","long", "GetDesktopWindow","int",0)
$resultx = DllCall("user32.dll","long", "GetDesktopWindow")
;msgbox(0, "",@error)
MsgBox(262144, "","Desktop hwnd "& $resultx[0] )

#cs
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal 
hWnd2 As Long,  ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
#ce



; $hwnd3 = DLLCall("user32.dll","int","FindWindowEx","int",$hwnd2[0] ,"str","","hwnd","Edit")
$hwnd3 = DLLCall("user32.dll","long","FindWindowEx","hwnd",$hwnd[0] ,"str","Edit","str","")
  MsgBox(262144, "", @error )
  MsgBox(262144, "", $hwnd3)
  MsgBox(262144, "", $hwnd3[0])
 MsgBox(262144, "", $hwnd3[1])
 
 $dec = StringRight ($hwnd3[1],"8" )
;msgbox(0, "", $dec)
$dec2 = Dec($dec)
msgbox(0, "",$dec2)




#cs
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, 
ByVal wMsg As Long,  ByVal wParam As Long, ByVal lParam As Long) As Long
   PostMessage WinWnd, WM_CLOSE, 0&, 0&
#ce
;Global Const WM_CLOSE = 1
$close = DllCall("user32.dll", "int", "PostMesage", "hwnd", $hwnd[0], "int", 3 ,"int",0,"int",0)
MsgBox(262144, "", @error)
MsgBox(262144, "", $close)
gBox(262144, "", $close[0])
#cs
ap'guide
Declare Function GetFileSize Lib "kernel32" Alias "GetFileSize"
(ByVal hFile As Long, lpFileSizeHigh As Long) As Long
#ce


MsgBox(262144, "", _WinGetClassName($hWnd[0]))
Func _WinGetClassName($hWnd)
    $x = DLLCall("user32.dll","int","GetClassName","hWnd",$hWnd,"str","","int",64)
    If Not @error And $x[0] <> 0 Then Return $x[2]
    Return ""
EndFunc
Edited by Lapo
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...