|
-
May 8th, 2002, 12:00 AM
#1
VBScript and API
Hi
How can i declare an api function in vbscript?
this is in VB:
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
How can i use this function (and others) in VBScript?
Thanks
Limor
-
May 8th, 2002, 02:40 PM
#2
Re: VBScript and API
Why don't you give it a try... looks like the hard work is done.
-
May 8th, 2002, 07:10 PM
#3
Re: VBScript and API
You cannot use API functions from VBScript directly. There are a bunch of reasons I could come up with why this isn't possible (like the Declare statement simply doesn't exist in VBScript), but the bottom line is that you can't.
What you can do, is create a class that can do that (written in VB), and create an instance of that class in VBScript. Something like this:
'Class1
Declare Function ShellExecute ...
public Sub DoShellExecute(strFile)
ShellExecute strFile, ...
End Sub
' VBScript
Dim obj
set obj = CreateObject("Project1.Class1")
obj.DoShellExecute("c:\my documents\document1.doc")
Of course, it will be required to registe the class on the machine running the VBScript
Tom Cannaerts
[email protected]
Moderator on http://www.vbcodelibrary.co.uk/board
A bottomless pit, I'm sure it came with the place, who would dig one on purpose?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|