Windows API Functions

Just starting out? Need help? Post your questions and find answers here.
Rogue
User
User
Posts: 10
Joined: Wed Jul 09, 2003 12:27 pm
Location: Michigan

Windows API Functions

Post by Rogue »

I was recently converting a little loop speed test program from IBasic and looked for a way to get ticks. After a fair amount of searching I came accross the GetTickCount_() function. What I find troubling is that I cannot find anything in the documentation about this shortcut. Is there something that I missed? I downloaded ApiViewer 2003 which had a PureBasic syntax plugin and it shows:

Code: Select all

OpenLibrary(0,"kernel32.dll")
CallFunction(0,"GetTickCount",)
which was what I was going to use but GetTickCount_() is cleaner. Can anyone point to where it talks about this type of shortcut?

Code: Select all

x.f = 1
y.f = 1.000001 

; change to desired amount of loops 
howManyLoops = 100000000

OpenConsole()
PrintN("")
PrintN("Running Benchmark of "+Str(howManyLoops)+" loops.")

starttime = GetTickCount_() 
For i = 1 To howManyLoops
   x = x * y
Next i 
stoptime = GetTickCount_() 

totalSeconds.f = stoptime - starttime 
totalSeconds = totalSeconds / 1000 

PrintN("")
PrintN("Computer ran through "+Str(howManyLoops)+" loops in "+StrF(totalSeconds,2)+" seconds.")
PrintN(""):PrintN(""):PrintN(""):PrintN(""):PrintN(""):PrintN("Press almost any key to continue.") 
Repeat:Until Inkey()<>""
CloseConsole()

End
Where ever you go, there you are.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Any function ending with an underscore is a WinAPI function.. Something like 600 API functions are directly available through PureBasic though I'm not sure it is documented anywhere...
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Windows API Functions

Post by PB »

> Can anyone point to where it talks about this type of shortcut?

It's all in the FAQ: viewtopic.php?t=4876

Specifically, look for 'Why do some commands end in an underscore' in
the FAQ, and it links off to details about using API commands. :)
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

API functions are built into windows.

In C/C++ these functions are made available by including Windows.h

In Visual Basic and Ibasic you have to declare the function.

In PureBasic, the functions are just available. This is because PureBasic is wonderful :)

The functions are all declared in the compilers support files.

If you take a look at Purebasic\PureLibraries\Windows you'll find Kernal32. In that file you'll see that GetTickCount is delcared.

So, the big question is, how do you find out how to use all of these functions?

The ultimate source is the Windows SDK from microsoft, as linked to by the FAQ:
http://www.mvps.org/vb/code/Win32api.zip

Personally I don't find this very useful. My personal favourite reference is AllApi.net's ApiGuide. This has lots of VB examples listed by functionality.
http://www.mentalis.org/agnet/apiguide.shtml

Converting VB API code to PB mainly involves deleting 90% of the code:)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Converting VB API code to PB mainly involves deleting 90% of the code

It's great, isn't it? :D
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

To get a description of WinAPI commands put this file:

http://www.garyw.uklinux.net/PB/WIN32.zip

into your PureBasic folder then put your cursor over a command and hit F1 :D
--Kale

Image
Post Reply