Sign in to follow this  

UINT,LPCSTR,DWORD what are they?

Recommended Posts

They are a strange mix of conventions (what follows are TYPICAL definitions):

typedef unsinged int UINT; // Unsigned INTeger
typedef char * LPCSTR; // Long Pointer to Character String
typedef unsigned long DWORD; // DoubleWORD

In Microsoft's Hungarian Notation scheme for naming variables, the prefix 'lp' stands for "long pointer", 'c' stands for "character" and 'u' stands for "unsigned". From the old days of programming, pointers could be long or short, depending on how far away in the absolute memory address your data was (due to the convoluted addressing schemes of old Intel chips). Nowadays, ALL pointers are long pointers, but Microsoft insists on still using "lp"!

A doubleword is two words, and what a "word" is exactly is often ambiguous. Typically, a word is the "bittage" of your processor, so if you have a 32-bit processor then the word size is 32 bits. However, a word can also mean 16 bits, which is what I believe the word size was when people started using "word" and "doubleword" to describe memory. Hence, DWORD is typically defined as 32 bits.

The idea behind using these typedefs is twofold. First, they are a convenience to type! Second, and more importantly, they let your program be easily updated to new architectures. For instance, on some machines an "int" may not be 32 bits! Hence, if you used the LPCSTR convention to declare all of your variables and you suddenly found that you actually wanted your strings to be Unicode, you can just change the definition to "long *" and it would change every variable declaration in your program!

Share this post

Link to post
Share on other sites
I thought I'd comment on the above two posts as well, since they bring up interesting notational points.

>> LPCSTR = char* (long pointer to a C style string... C style = ends with a 0)
The typical prefix for a "ends with a 0" string is 'z'. Hence, a "long pointer to a 0-terminated character string" is LPZSTR.

>> LPCSTR is a pointer to a constant string (char* or wchar_t* for unicode).
The typical prefix for "constant" is 'const' or 'k' (note these are typically only for formal parameters). Hence, a "constant long pointer to a character string" would be: KLPCSTR. This prefix is rarely used, however.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this