Confusion Calling DLLs vs Calling Win32

Just starting out? Need help? Post your questions and find answers here.
JElliott
User
User
Posts: 16
Joined: Mon Sep 03, 2007 3:44 pm
Location: Connecticut, USA

Confusion Calling DLLs vs Calling Win32

Post by JElliott »

Be gentle with me :) - this is my first PB excursion into the world of Win32 API and DLLs. I'm confused about calling the Win32 API and other DLLs. In the two examples below I'm calling two different DLLs neither of which has constants that PB recognizes - My first question is why not? Does this mean the constants (and thus the DLLs) are not part of the Win32 API?

My second question is I have to load the Winhttp.dll but not the Wininet.dll my assumption is that something else loaded the Wininet.dll? Also I can use the Func_ method to call the Wininet.dll but have to use the CallFucntion method for the Winhttp.dll.

Is there a way to call the Winhttp.dll. via the Func_ method?

Hope you can follow my ramblings and can offer some insight.

Thanks,
Jeff

Code: Select all

;Requires Winhttp.dll & Wininet.dll

#INTERNET_OPEN_TYPE_DIRECT = $1
;
#WINHTTP_ACCESS_TYPE_NO_PROXY = $1
#WINHTTP_NO_PROXY_NAME = #Null
#WINHTTP_NO_PROXY_BYPASS = #Null
#WINHTTP_FLAG_ASYNC = $10000000

Procedure doPost()
  ; Example 1 requires Winhttp.dll)
  winHTTPlib.l = OpenLibrary(#PB_Any,"Winhttp.dll")
  Debug IsLibrary(winHTTPlib)
  ;WinHttpOpenHandle.l = WinHttpOpen_("User Agent",#WINHTTP_ACCESS_TYPE_NO_PROXY,#WINHTTP_NO_PROXY_NAME.,#WINHTTP_NO_PROXY_BYPASS,#WINHTTP_FLAG_ASYNC)
  WinHttpOpenHandle.l = CallFunction(winHTTPlib,"WinHttpOpen","User Agent",#WINHTTP_ACCESS_TYPE_NO_PROXY,#WINHTTP_NO_PROXY_NAME,#WINHTTP_NO_PROXY_BYPASS,0)
  Debug WinHttpOpenHandle
  CloseLibrary(winHTTPlib) 
  ;
  ; Example 2 requires Wininet.dll
  internetOpenHandle.l = InternetOpen_("User Agent Info Goes Here",#INTERNET_OPEN_TYPE_DIRECT,"","",0)
  Debug internetOpenHandle
  InternetCloseHandle_(internetOpenHandle)
  ;
EndProcedure
doPost()
jorgejones
User
User
Posts: 32
Joined: Tue Mar 21, 2006 8:27 am

Post by jorgejones »

pb doesnt really have support to every winapi library by this i am saying that it doesnt have the headers (constants etc) defined by default for this libs but you obviously can still gather this from the api vendor and manage it on your own or add them to the pool

what is your actual prblem? src ran just fine here
JElliott
User
User
Posts: 16
Joined: Mon Sep 03, 2007 3:44 pm
Location: Connecticut, USA

Post by JElliott »

thanks for the response -- but my problem was not an actual code problem. - perhaps I'm in the wrong place with my questions - I was trying to get answers to the specific questions in my post.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

JElliott, it does seem to me that jorgejones has done a good job of answering your specific questions! He has explained that PB does not directly import every Win api library by default or indeed place the definition of every constant / structure from all of the SDk header files into it's resident files. Such an undertaking would take months!

Purebasic makes directly available a large chunk of the Win api; certainly all of the 'regular' api libraries are directly available.

Others, like Winhttp.dll have not been directly imported as yet. Now this could be an oversight, or a simple case of there not being enough hours in the day for Fred and co! The fact is that, as you've demonstrated yourself with OpenLibrary() etc. there is nothing preventing you from accessing these libraries. Although instead of OpenLibrary() I would consider using Import / EndImport.

If you feel that the Winhttp.dll library should be imported by default then make a post in the Features Request forum etc.
I may look like a mule, but I'm not a complete ass.
Post Reply