1

how can call dll export faunction in vb6? CallWindowProc have limtied in paramet. in example how call this fanction ?

Dim lb As Long, pa As Long
lb = LoadLibrary("wininet.dll")
pa = GetProcAddress(lb, "InternetOpen")
9
  • 1
    Why would you want to use LoadLibrary and GetProcAddress instead of just declaring the function to access it? Commented Jan 23, 2018 at 9:54
  • @vincent-g Checking vb language restrictions Commented Jan 23, 2018 at 10:06
  • 1
    CallWindowProc is expected to be used for hooking/subclassing, not invoking some random function. Calling a dll function in vb6/vba is expected to be done using a Declare statement. Commented Jan 23, 2018 at 10:36
  • @vincent-g There is no way to do this? Commented Jan 23, 2018 at 13:30
  • May be @user2522767 needs to load dll dinamically at run time? Commented Jan 23, 2018 at 13:33

1 Answer 1

1

These definitions are copied from pinvoke.net and modified the variable types for vb6.

I have not tested this code.

Const INTERNET_OPEN_TYPE_PRECONFIG = 0  ' use registry configuration
Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net
Const INTERNET_OPEN_TYPE_PROXY = 3  ' via named proxy
Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 ' prevent using java/script/INS

Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" ( _
    ByVal sAgent As String, _
    ByVal lAccessType As Long, _
    ByVal sProxyName As String, _
    ByVal sProxyBypass As String, _
    ByVal lFlags As Long) As Long

Usage:

Dim hInet As Long
hInet = InternetOpen("HttpAgent", INTERNET_OPEN_TYPE_PRECONFIG, _
  "", "", 0)
If hInet = 0 Then 
  'Return or handle a False return status
End If
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.