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 Discussion / Something interesting i found out about dbc and dlls

Author
Message
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 28th Apr 2009 17:43
if the dll call takes a type LPCSTR (or any pointer) then dbc passes the pointer to your variable for you. i was messing around with a dll and made function to get the text of a window and you can pass a string variable to it and without returning a value the variable in dbc changes. kinda usefull in my oppinion.

New Site! Check it out \/
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Apr 2009 23:43 Edited at: 29th Apr 2009 02:50
@Caleb1994
It makes sense if you think about it. A string, is a series of bytes, one after another all linked together like a, well you guessed it, string. It's really like an array of bytes. It's length can change so it's not like an integer or a float where the number of bytes is fixed. When you use commands like MID$() or LEFT$() etc., you are actually referenceing memory pointer positions within the string relative to the start of the string's memory address.

Even the type LPCSTR gives you a clue: LP means long pointer, so you have to pass a 4 byte DWORD or long as a memory address. C means that the pointer is a constant, and STR is to help you identify that it is a character string that you are dealing with. And if it's a character string then the type is char which is equal to 1 byte per memory position. So if you read LPCSTR outload it might sound like "A Long Pointer Constant to a Character String". If there was a W in the type, LPCWSTR, that would mean an unsigned short or a WORD, is the pointer type. That means it requires 2 bytes for each character per memory position. This is for unicode values - international character sets and the like. That is why you will see winapi dll functions with an A or a W at the end. A is for ascii and w is for unicode. For DBC, it's best to use the functions with the A on the end because I don't think DBC passes unicode values.

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 29th Apr 2009 02:00
Ya i geuss that makes since when you think about it. lol

I never knew LP meant long pointer i knew it had something to do with pointer though lol

and actually the C int LPCSTR means constant. if you look at the defenition in c++ LPSTR is a CHAR pointer and LPCSTR is const CHAR pointer.

New Site! Check it out \/
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Apr 2009 02:44
Woop woop! Oops! Good catch! I just looked up the def to see why I missed that and of course you are right:

typedef CONST CHAR *LPCCH,*PCSTR,*LPCSTR;

I better change it above so passerbys aren't misinformed. Tanks!

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 29th Apr 2009 03:15
hahaha ya one good thing about VC++ is you just hover over a function,type,class,definition,variable and it tells you what type and parameters(if necessary) and stuff it has. lol

New Site! Check it out \/

Login to post a reply

Server time is: 2025-06-08 05:47:07
Your offset time is: 2025-06-08 05:47:07