Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / simple api for newbie

Author
Message
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 8th Apr 2007 22:23
this is a simple sample that opens your cd-rom with only api i will post more advanced ones later including tcp/ip with use of api

you can use depends to see the api commands of winmm.dll and all other windows dll files

new learning center comming soon http://911.bounceme.net/
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 8th Apr 2007 22:41 Edited at: 8th Apr 2007 23:18
this code will open cd-rom and then open notepad

this opens desktop coltrol panel


more samples will be included

new learning center comming soon http://911.bounceme.net/
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 9th Apr 2007 03:01 Edited at: 9th Apr 2007 03:03
here is some code to play a .mid file in dbpro

more to come

new learning center comming soon http://911.bounceme.net/
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 9th Apr 2007 04:58
open notepad for this example
this is a hide window example and how to show it again

more to come

new learning center comming soon http://911.bounceme.net/
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 9th Apr 2007 05:26
I didn't know you could call Dlls in DBP...

Great stuff!! Mind explaining it for the Noobs like me?

"There will always be evil, for, without evil, the good shall lose their virtue."
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 9th Apr 2007 05:33
What do you want explained? I have some experience with the Windows API.

Cheers,

-db


"We arent terrible people.... Horses are terrible people." - Peter Griffin
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 9th Apr 2007 05:41
How do you find out what the DLLs do? I'm trying to Google it right now...

"There will always be evil, for, without evil, the good shall lose their virtue."
Xenocythe
18
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 9th Apr 2007 05:43
It should be on MSDN somewhere

Anyone got the linky?

Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 9th Apr 2007 05:46
I'm finding stuff about an export table. What is that? How do you get to it?

"There will always be evil, for, without evil, the good shall lose their virtue."
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 9th Apr 2007 05:50
You can find out what DLLs do by searching through MSDN, or, by looking through their API (Like, windows.h (A c++ file)).

Cheers,

-db


"We arent terrible people.... Horses are terrible people." - Peter Griffin
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 9th Apr 2007 05:59 Edited at: 9th Apr 2007 06:01
look up depends viewer it will show you all the dll functions then look on msdn for the functions for eample shell32.dll open it with depends then you can look up the functions on msdn also get spy++ to view the classes (window handles)
i'm working on a tcp/ip api tutorial wich i will post all fully commeted and i'm also gona post some more advanced api features for ppl that want to learn more not just the noobies but for everyone it will include all functions from every windows dll file all calls are from dbpro.Now remember there is no special dlls being used here just the regular dark basic pro commands and the windows xp dll files.

new learning center comming soon http://911.bounceme.net/
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 9th Apr 2007 06:11
this one hides your start bar

more to come

new learning center comming soon http://911.bounceme.net/
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 9th Apr 2007 06:21
I couldn't find Depends viewer yet. I did find Dependency Walker, which shows me what I can call with a DLL, but not what it does or what properties it uses.

"There will always be evil, for, without evil, the good shall lose their virtue."
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 9th Apr 2007 07:06 Edited at: 9th Apr 2007 07:10
here is link http://www.dependencywalker.com/depends22_x86.zip
ok the export table is the functions that you see in depends
like FindWindowA in user32.dll it is in the windows->system32 directory
planetsourcecode.com do a search on api there is some vb samples that can be converted to dbpro.
also look in the c++ section on there

new learning center comming soon http://911.bounceme.net/
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 9th Apr 2007 07:12
this one hides desktop icons


new learning center comming soon http://911.bounceme.net/
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 9th Apr 2007 08:08
here is api how to empty recycling bin
set window size 800,600
load dll "shell32.dll",1
call dll 1,"SHEmptyRecycleBinA",0,"",hex$(02)
do
loop
more to come

new learning center comming soon http://911.bounceme.net/
z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 9th Apr 2007 08:11
Nice code snippets you got there, I may need to use one sometime.

~ z_man ~
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 9th Apr 2007 10:39 Edited at: 9th Apr 2007 10:40
Why not dll export viewer?

Cheers,

-db


"We arent terrible people.... Horses are terrible people." - Peter Griffin
Skull Bones
17
Years of Service
User Offline
Joined: 8th Apr 2007
Location: FPSC
Posted: 9th Apr 2007 12:36
what is the point of emtying your recycle bin? i thought its about db pro.
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 9th Apr 2007 17:42 Edited at: 9th Apr 2007 17:43
theses are samples of how to use api i have seen many ppl asking about it so i made these to show them how to do dif things with the dbpro language all of this is done useing dbpro commands
some ppl may want to use dbpor lang to make thee own desktop besides a game.

new learning center comming soon http://911.bounceme.net/
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 9th Apr 2007 17:50
your doing great White knight , have you work out how to get this one working.



No worries if not possible.

Dark Physics makes any hot drink go cold.
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 9th Apr 2007 20:21
well i don't have my printer hooked up so i can't work on the print gui yet i'll see what i can do

new learning center comming soon http://911.bounceme.net/
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Apr 2007 00:41
There are some cool things you can do with the animate window function If you set the duration to about 5000 ms, you can slide the window in and stuff

Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 10th Apr 2007 02:12
Quote: "Why not dll export viewer?"


Because google didn't tell me about it. Got a link?

"There will always be evil, for, without evil, the good shall lose their virtue."
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 10th Apr 2007 03:07 Edited at: 10th Apr 2007 03:13
Start here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdkintro/sdkintro/devdoc_platform_software_development_kit_start_page.asp

Those DLL viewer programs are not that helpful, imo. The Platform SDK is, however. At any rate, you will not get far without some sort of documentation. The one above is the best, as it is from MS, and free.
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 10th Apr 2007 03:12 Edited at: 10th Apr 2007 03:22
Ankillito i gave you link to one check the link i my post depends
if you can get visual studio 6 read the help files from there it has a bunch of api stuff in it and teaches you how to use the dlls in vb and c++ but can be ported to dbpro
.net is not really recomended for porting though.

new learning center comming soon http://911.bounceme.net/
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 10th Apr 2007 03:16
Quote: "Start here"


Thx. I have Chem homework to do now, but I'll check into it.

@White Knight - I did download Dependency Viewer. It does help by showing the functions the DLL allows, but not what they do or what parameters it uses. Do I just have to toy around with it? I'd be afraid of breaking my computer...

"There will always be evil, for, without evil, the good shall lose their virtue."
White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 10th Apr 2007 05:38 Edited at: 10th Apr 2007 05:39
ok well i'll either look for the reference or make a api list that shows the api with the parameters to use
i have a api viewer that shows the api functions and not just the exports.

new learning center comming soon http://911.bounceme.net/
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 10th Apr 2007 06:17
@White Knight:

not sure I followed that. How a bout you just post a tutorial on how to figure this out for ourselves sometime...

"There will always be evil, for, without evil, the good shall lose their virtue."
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 10th Apr 2007 06:52 Edited at: 10th Apr 2007 19:31
[never mind]
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 10th Apr 2007 07:11 Edited at: 11th Apr 2007 02:16
Thx. I guess I have [too] much jet-lag to really think about this right now...

"There will always be evil, for, without evil, the good shall lose their virtue."
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 10th Apr 2007 10:39
Click here for the link.

Cheers,

-db

PS: Keep up the good work.


"We arent terrible people.... Horses are terrible people." - Peter Griffin
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Apr 2007 15:29
White knight, this might be usefull to some if you can work out how to use it, all to do with drop down menus.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/menus/menureference/menufunctions/destroymenu.asp

As and when ever you want to do this.

Cheers.

Dark Physics makes any hot drink go cold.
Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 10th Apr 2007 15:46
Could somebody make code how to retive Current Window title bar i ahve tried many times and always get crash



HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 10th Apr 2007 16:16
is this the one you are using to get it, can't tell you how to do it, but maybe pointing you the right way.



Dark Physics makes any hot drink go cold.
Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 10th Apr 2007 16:59
I know the functions and i know how to do this in visual basic but it crashes on dbpro .. Do i need to get memory with dbpro or something?



jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 10th Apr 2007 19:30 Edited at: 10th Apr 2007 19:34
Yes, you do...you need a buffer for it to put the text in, that is what a LPSTR is...a pointer to a string buffer.

===== That is a good example of a question that you could answer with the Platform SDK. =====

Use a DBPro string, but initialize it to a set length by using space$. That is the easiest way.

myStr = space$(256)...then you can pass myStr as the LPSTR, and the size as 256.
Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 10th Apr 2007 22:07 Edited at: 10th Apr 2007 23:31
Got working thank YOU!!




Question 1.

Can u send email with winapi? I havent found any function on api-guide..

(I need this cuz gogas smtp plugin isnt working for me..)

Question 2.

Can u check if shift/tab key is pressed with winapi? Or can you check are u typing lower or uppercase.. Thank You!



Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 11th Apr 2007 02:22
The GUI portion of related Window API commands have not need for concern. A free Windows GUI plugin is available, and open source.

@The Full Metal Coder Roxas
You just gave me an idea. Thank you.


Cheers,

-db


Albert Einstein believed that imagination is more important than knowledge.
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 11th Apr 2007 02:23
Quote: "Click here for the link. "


Up and Running! Thx! Still wondering what each function does though. I guess I have to just google each one separately.

"There will always be evil, for, without evil, the good shall lose their virtue."
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 11th Apr 2007 02:25
Well, glad I could help. I enjoy dllexp because its not quite as complicated looking as the one you previously used. At least to me. I to want to find something which can display the parameter types to the functions. If you have any success please tell me.

Cheers,

-db


Albert Einstein believed that imagination is more important than knowledge.
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 11th Apr 2007 02:49
Quote: "I to want to find something which can display the parameter types to the functions. "


If you can find that, and post a link, I will build a shrine in your name!!

-And I just went to Japan, so I got a few ideas. Supposedly 1000 is the number of perfection. I'd hang 1000 CDs, each with the app on it, or something....

"There will always be evil, for, without evil, the good shall lose their virtue."
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 11th Apr 2007 02:53 Edited at: 11th Apr 2007 03:17
lol. I want to go to japan. Sorry, just reminded of that. Anyways, its ok. If I cant find it, i'll probably build a quick DOS program to save all the commands to a file. Perhaps with formats on how to save them.

Anyways, if anyone is interested, my source code to my WinGUI has been posted. I think it would be usefull for this here thread. Click here if you want to view it.

Cheers,

-db

[edit]
You may want to start work on that shrine if you are really going to do it, lol. Click here for the parameter viewer
[/edit]

[edit2]
Ok, nevermind that link, it did not seem to work for an example DLL I had.
[/edit2]

[edit3]
Ok, now begin the shrine building, lol. Want to view DLL function parameters? Click here!

Click on "Export" to see the functions in the DLL.
[/edit3]

[edit4]
And here is the proof of it working. Image attatched. I chose a DBP DLL because I find it would be more likely you would all understand the parameters. As you can see, i'm merily browsing through the DBP DLLs.
[/edit4]


Albert Einstein believed that imagination is more important than knowledge.

Attachments

Login to view attachments
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 11th Apr 2007 03:12
np.
Yes, the dll is mapi32.dll There are tons of dlls for networking.
Again, this is all covered in the Platform SDK.
jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 11th Apr 2007 03:19 Edited at: 11th Apr 2007 03:20
sri
Gamers for sale
18
Years of Service
User Offline
Joined: 19th Nov 2005
Location: Some where beneath the elements
Posted: 11th Apr 2007 04:03
I have played around with windows api for quite a while and can show you how to call windows api commands in visual basic. I can make this into a tutorial if anyone is interested.

Go to this site and download the API guide:
http://allapi.mentalis.org/agnet/apiguide.shtml

This will give you a good list to use of windows api commands.

The functions are in VB and VB.Net, so you need to know how to convert them.

Here's a basic beep function:


This is in VB code.

To make this in Dark Basic Profession code you have to know what parts you are using.

The part that says:


This is the dll or lib that you can find the function.

To load the dll just use:


The next part is calling the function:

Where it says:



"Beep" is the function and the parameters are in the ().

Just ignore the ByVal.

From the API guide:



The dwFreq is the frequency in hertz as it says. The range is different on different computers. This model is used for windows NT which I would guess nobody has. I would guess that they would have Windows XP or a more reasent operating system.

The Range for Windows XP is 7000 max and about a 100 min. I had to figure these values. It's the lowest you can hear to the highest you can hear.

From the API Guide:


As it says the dwDuration parameter is the length in milliseconds that you want your tone to play.

A warning: Note that you can set this to a really high number and the Dark Basic Professional app will pause until the sound is complete and I have had this happen to my computer by putting the code in a do loop, SO DON'T TRY IT...and don't tell me because I told you so!

To call the dll you would use the call dll command except use () to show that you want to return something.

The dll will return a non zero value (float) if it was successful. If it didn't work then a zero would be returned.

Notice: When using windows api functions you have to keep the function the same. Can't have an lowercase (b) when it requires an uppercase!

Here's the code:



Final Code snippet:


Let me know if you need any more help with windows api!

gamersforsale

Gamers for sale
18
Years of Service
User Offline
Joined: 19th Nov 2005
Location: Some where beneath the elements
Posted: 11th Apr 2007 04:08 Edited at: 11th Apr 2007 04:08
@DB user 2006+
I checked out your winapi dll nice job. I was having problems with loading a dll in c++. Which command do you use?

White knight
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location:
Posted: 11th Apr 2007 04:28 Edited at: 11th Apr 2007 04:46
well this thread is to teach ppl how to make api calls with dbpro although there is other open source tutorials that have to do with c++ and vb but this thread was aimed more for dbpro without plugins
if anyone else has some tutorials on api and dbpro go ahead and post them here. but when posting please comment it so noobies can follow along.
not to get off the subject there is a windows clone here if anyone is interested it can run most opengl games there working on directx support also http://www.reactos.org
it has alot of the same api as microsoft windows xp but with sourcecode to learn from for instance shell32.dll kernel32.dll and more.I'm working on a program that shares calls from opengl and directx api from dbpro i am just seeing what all can be done with the api it's self
there should be documentation on the files on there also they work in windows xp just fine.

new learning center comming soon http://911.bounceme.net/
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 11th Apr 2007 04:39
LoadLibrary is the command I use. Use it like so:



Cheers,

-db


Albert Einstein believed that imagination is more important than knowledge.
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 11th Apr 2007 07:41
Um, about the shrine, I meant if it was free. Oh well, I'll just buy it and charge YOU for the shrine!!!

"There will always be evil, for, without evil, the good shall lose their virtue."

Login to post a reply

Server time is: 2024-04-24 13:20:26
Your offset time is: 2024-04-24 13:20:26