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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Wndows API in VBScript

Status
Not open for further replies.

AskMan

Technical User
Oct 15, 2002
36
FR
Hi,

First, I'm sorry if my english is not very fluent ... :eek:)

I would like to use the Windows API in a script, but I already got errors.

If someone can help me.

Thanks
 
Can you please detail the errors you are getting also example of code you are using.

Regards
Steve Friday
 
By example, the following code works in a VB module, but I can't use it in a VBScript.
The error always occurs during the declaration of the API:
- Line : 3
- Caract : 17
- Code : 800A0401
- Source : Compilation Error

So, I don't know if I can use the Windows API

Thanks for your answer

--------------------------------------------------
Option Explicit

Private Declare Function GetPrivateProfileString& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String)


MsgBox(LireKeyIni("mySection","myKey","myFile"))

Public Function LireKeyIni(section$, key$, file$)

Dim N, valeur$
valeur = String(255, 0)

N = GetPrivateProfileString(section, key, "", valeur, 254, file)
If N > 1 Then
valeur = Left$(valeur, N)
End If

LireKeyIni = valeur
End Function
----------------------------------------------
 
VBScript doesn't support API calls, you have to create an ActiveX component that does the actual calls. You may find several such scripting "helper" components on the web.

One place to start is
You can also create your own API-interface components using VB. VB5 Control Creation Edition is a great option for those who don't have VB5 or VB6. See if you want to explore this option.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top