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.

DLL Talk / DLL question (kernel32.dll)

Author
Message
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 27th Apr 2005 03:21
Found this on msdn

BOOL GetUserName(
LPTSTR lpBuffer,
LPDWORD nSize
);


how would i convert this to dark basic pro language? i found it on the msdn pages. i've fidled with it for hours now. but i have a few problems.

what is LPTSTR? what is LPDWORD?

i dont understand any of this
EddieB
20
Years of Service
User Offline
Joined: 29th Sep 2004
Location: United Kingdom
Posted: 27th Apr 2005 03:25
I Guess LPDWORD nSize Is some sort of DWORD.
And LPTSTR lpBuffer is some sort of string holder.

[href]http:www.graphics-monkey.co.uk[href]
"Him? A guru? Rich is the guru, David T is just good"
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 27th Apr 2005 03:27 Edited at: 27th Apr 2005 03:35
whats a dword then? excuse my stupidity.

i tried to read alot about this dword and stuff, but i dont understand it.
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 27th Apr 2005 03:59
First of all this function is not in the Kernel32.dll but in Advapi32.dll.

LPSTR is a buffer that'll receive in null terminated string and LPDWORD is a pointer to a DWord (that's similar to an Integer (same size) but can only store positive value). In PlayBasic the code would look like this:




Play Nice! Play Basic! Version 1.06
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 27th Apr 2005 04:03 Edited at: 27th Apr 2005 04:04
And how would it look in Dark Basic Pro?

I dont have a clue what this poke and pointer stuff means
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Apr 2005 04:03
?

Well, the code in DBPro is like this:



*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 27th Apr 2005 06:22
GetUserName(LPTSTR,LPDWORD) function [Base]
The GetUserName function retrieves the name of the user associated with the current thread.
http://msdn.microsoft.com/library/en-us/sysinfo/base/getusername.asp

Source of this info
http://forum.thegamecreators.com/?m=forum_view&t=53067&b=18
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 27th Apr 2005 06:34
There are a lot of links that come up on this topic, but when I go to any of them, they are blank pages.
Maybe there was a security issue with this?
Or maybe you need to subscribe?

Anyway, in my looking around I found a free copy of visual studio beta, if you want one.

http://msdn.microsoft.com/visualc/
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 27th Apr 2005 15:53
But it cant be used with DBPro...

Visit http://homepages.nildram.co.uk/~nickk
Calm down dear! Its only an election...
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 27th Apr 2005 16:44
Sorry I got the game creators web address posted, Didn't mean to do that. I do not see very well, especially small type. Thought I was posting the one I just made a copy of, so I lost that correct web link.
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 27th Apr 2005 18:43
NoteJam: i know where to find the info on msdn, but i dont know what lptstr and lpdword means
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Apr 2005 21:06
Read the code in my post - I have descriptions of these in the code.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 27th Apr 2005 21:58
Ah, yes thank you IanM I'll have a look at it, so far it seems to makes sense
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 29th Apr 2005 16:05
I found this. LPSTR means a long pointer string.


Win32 Data Types
You will find that many of the normal keywords or types have windows specific definitions, UINT for unsigned int, LPSTR for char* etc... Which you choose is really up to you. If you are more comfortable using char* instead of LPSTR, feel free to do so. Just make sure that you know what a type is before you substitute something else.
Just remember a few things and they will be easy to interpret. An LP prefix stands for Long Pointer. In Win32 the Long part is obsolete so don't worry about it. And if you don't know what a pointer is, you can either 1) Go find a book or tutorial on C, or 2) just go ahead anyway and screw up a lot. I'd really recommend #1, but most people go with #2 (I would . But don't say I didn't warn you.

Next thing is a C following a LP indicates a const pointer. LPCSTR indicates a pointer to a const string, one that can not or will not be modified. LPSTR on the other hand is not const and may be changed.

You might also see a T mixed in there. Don't worry about this for now, unless you are intentionally working with Unicode, it means nothing.

Dword, isn't that a double word? a word is two 8bit bytes, so a Dword is 4 bytes long, or 32 bits long.

Think you might be able to find a definition list of this and other varible types you might run into at msdn in a c++ or c compiler docs on varible types allowed by the compiler?
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 29th Apr 2005 16:13
Alright, Bingo, found it.

Often, the documentation that you might find for an API will be written for a C++ programmer. Here's a short table which helps you translate the C++ variable type declaration to its equivalent in Visual Basic:

ATOM ByVal variable as Integer
BOOL ByVal variable as Long
BYTE ByVal variable as Byte
CHAR ByVal variable as Byte
COLORREF ByVal variable as Long
DWORD ByVal variable as Long
HWND ByVal variable as Long
HDC ByVal variable as Long
HMENU ByVal variable as Long
INT ByVal variable as Long
UINT ByVal variable as Long
LONG ByVal variable as Long
LPARAM ByVal variable as Long
LPDWORD variable as Long
LPINT variable as Long
LPUINT variable as Long
LPRECT variable as Type any variable of that User Type
LPSTR ByVal variable as String
LPCSTR ByVal variable as String
LPVOID variable As Any use ByVal when passing a string
LPWORD variable as Integer
LPRESULT ByVal variable as Long
NULL ByVal Nothing or ByVal 0& or vbNullString
SHORT ByVal variable as Integer
VOID Sub Procecure not applicable
WORD ByVal variable as Integer
WPARAM ByVal variable as Long
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 29th Apr 2005 16:30
For additonal info take a look here at this tutorial.
LPDWORD seems to be a long pointer double word, my guess its a 32 bit or 4 byte pointer, and is used in the c++ language.



http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/groundsup/tut2
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Apr 2005 21:25
Quote: "You might also see a T mixed in there. Don't worry about this for now, unless you are intentionally working with Unicode, it means nothing"


It actually means quite a bit. If there is a T in one of your *STR types, then that means that there are two versions of the function. One with an A appended to the name for the ASCII version, and one with a W appended for the Unicode version (sometimes only one of these is available).

Calling these from DBPro, you will always want the one with the A on the end of the name.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 30th Apr 2005 05:23
Request: Can someone do a translation of those variables to dark basic pro? And can someone look over the dll doc i posted here under the code button?

What else do we need to add to this tutorial on making dll calls in dark basic pro?

If you see something that needs edited, please mention it. I have marked spots I think need edited with xxxedit .

I have also put some of your comments in there that seems important and of use.

NoteJam
19
Years of Service
User Offline
Joined: 11th Apr 2005
Location:
Posted: 5th May 2005 16:01
I looked in a c++ compiler, the docs for Bloodshed Dev C++ on topic varible types, and it does not mention most of the varibles in the table I posted. Are they C varibles? Or can the C and C++ language define varibles? I am trying to id the language used for these examples on the msdn web site, so I can look in the languages docs on what it says about the varible types. Please tell me what language it is.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th May 2005 22:41
They are specific to the windows SDK and are basically redefinitions of the standard C/C++ types - DWORD is an 'unsigned long' for example

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2024-11-21 14:34:56
Your offset time is: 2024-11-21 14:34:56