Import WinAPI Function in *.VBS File

一笑奈何 提交于 2019-12-12 09:34:42

问题


Using visual basic in say Excel, I am able to declare WinAPI functions using the DECLARE keyword - e.g.

Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" ( _
    ByVal Locale As Long,
    ByVal LCType As Long,
    ByVal lpLCData As String
) As Boolean

However when using this syntax in a *.VBS file - it fails with a compile error.

Can anyone tell me what I need to do to run WinAPI functions from *.VBS files?


回答1:


You can't run WinAPI functions from VBScript without some extra third-party support.

I believe there used to be vendor of a COM component which allowed VBScript to call into a standard dll but I can't remember what it was called and its quite possible that my imagination is playing tricks on me.




回答2:


Plenty of forum posts mention 'dynacall' as the wrapper I think you're talking about however the two main links they post seem defunct

For what it's worth HTA may be worth looking at as an easy to use substitute http://www.microsoft.com/downloads/en/details.aspx?FamilyId=231D8143-F21B-4707-B583-AE7B9152E6D9&displaylang=en



来源:https://stackoverflow.com/questions/2325468/import-winapi-function-in-vbs-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!