Solved

win32api from vbscript ???

Posted on 2001-07-24
12
404 Views
Last Modified: 2008-03-10
is it possible ? if so - what's the syntax. tried regular vb declaration :

Declare Function etc......

does not working.
0
Comment
Question by:AnswerTheMan
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6313235
Doesn't work from VBScript, you must call it from your MTS/COM+ object.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6313277
Dave is right, VBSCript doesn't allow direct access to API calls. You need to wrap these into an activex dll that you can instantiate a class from which makes the api calls for you. There are some functions available in WSHOM.ocx which are of use, it depends what you want from the api.
0
 
LVL 27

Expert Comment

by:Ark
ID: 6315114
Hi
Take a look on my sample at http://www.freevbcode.com/ShowCode.Asp?ID=1863

Make a class module from this code, compile it as activeX dll and use any API you want.

Cheers
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 2

Expert Comment

by:Caseys95
ID: 6317022
AnswerTheMan,

There is a good article in the May issue of Access/VB/SQL Advisor magazine. It discusses the use of WMI (Windows Management Instrumentation)

Quotes:

"Thanks to the Windows Management Instrumentation, you may never need to directly access the Windows API again"

"WMI was originally designed for scripting languages, such as VBScript and JavaScript, but you can use almost all the programming interfaces and objects in any application that understands COM components."
0
 
LVL 5

Author Comment

by:AnswerTheMan
ID: 6322871
Dave Greene & TimCottee
--------------------------
yeah, that's what i was thinking.


ARK
----
i meant calling API from the script itself.
without instanciating any object that runs the api calls.


Caseys96
--------
i'll check that. do you have any URL ?
0
 
LVL 2

Expert Comment

by:Caseys95
ID: 6324008
http://advisor.com/Articles.nsf/aid/KIELD44

Not much help there though.

It will require using a COM object.
0
 
LVL 27

Expert Comment

by:Ark
ID: 6324683
Hi
It's not possible to call API from vbs without objects (note that WMI and WSHOM are objects too).
BTW, you even need no to make dll - smbd already did it:
http://home.att.net/~wshvbs/wshAPIToolkitObjectPage.htm

Cheers
0
 
LVL 5

Author Comment

by:AnswerTheMan
ID: 6331483
ok guys. it's not possible without objects, that is, you can call from VBS right to system dll by declaring it as in VB.
knew that, but wanted to be sure.
since didn't get any  fresh news - what you suggest to do with this Q ?
0
 
LVL 8

Accepted Solution

by:
Dave_Greene earned 100 total points
ID: 6331535
You should award the points if you have enough.  Even though proven to be impossible, much good information can be found in this thread!
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6345984
And definately beat up the experts on your way out...  I forgot to mention that, but I guess you have that one down pat.
0
 
LVL 27

Expert Comment

by:Ark
ID: 6346887
IMHO better 0 then C

Cheers
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6346891
yea, someone will really read this now... way to go!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question