Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

API though vbs

Status
Not open for further replies.

turtlemaster

Programmer
Oct 4, 2001
93
0
0
US
I have a vbs file that I want to use API calls in. It errors out on the declare statements though. How should I change the syntax to allow this to work.

Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Any, ByVal lParam As Any) As Long
Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Declare Function IsWindow Lib "user32.dll" (ByVal hwnd As Long) As Long

I'm not even sure I can do this. I hope so ... :)
 
You can't use API calls in VB script; only in actual programs.
 
try to encapsulate those apis in a custom class module using vb. compile that calss to acticex dll then u can call those winApis in ur vbs file by instantiating ur class module object

ComputerJin
 
I put the declares in a module of their own and call them from another module & no other processes than run. (Copied from a working program.) There was an intervening process where type &/or classes of variable need pointers and that involved a declaration of routines from the Win32 kernel also and a call to convptr or something (not at my machine) - effectively another conversion layer of pointers and variables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top