April 29, 2024, 10:43:50 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Include file containing all WinAPI types

Started by Kale, August 12, 2006, 03:13:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kale

Here is a file for including into your projects which creates all of the WinAPI types as if they were native. I know that Sapero has converted all of the Windows include files but this is a more lightweight version defining just the types.

This is for when you just want to import a few WinAPI functions into your source, so you don't have to include Sapero's uber files just to use the defined types.

All of these types are described here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/windows_data_types.asp

There are two defines that you need to use before you include this file for extended functionality.

1).  '#Define 64Bit' if you want to use the types to develop 64bit apps.
2).  '#Define Unicode' if you want the types to be used for unicode development.

If you don't use any of these defines then this include file will default to standard 32bit types and ASCII chars.

WindowsTypes.inc

// Dyanamic Size Types

#ifdef 64BIT
#typedef HALF_PTR INT
#typedef INT_PTR INT64
#typedef LONG_PTR INT64
#typedef PHALF_PTR POINTER
#typedef POINTER_32 POINTER
#typedef PUHALF_PTR POINTER
#typedef UHALF_PTR UNSIGNED INT
#typedef UINT_PTR UNSIGNED INT64
#typedef ULONG_PTR UNSIGNED INT64
#else
#typedef HALF_PTR WORD
#typedef INT_PTR INT
#typedef LONG_PTR INT
#typedef PHALF_PTR POINTER
#typedef POINTER_32 POINTER
#typedef PUHALF_PTR POINTER
#typedef UHALF_PTR UNSIGNED WORD
#typedef UINT_PTR UNSIGNED INT
#typedef ULONG_PTR UNSIGNED INT
#endif

// Unicode Types

#ifdef UNICODE
#typedef LPCTSTR POINTER
#typedef LPTSTR POINTER
#typedef PCTSTR POINTER
#typedef PTSTR POINTER
#typedef TBYTE UNSIGNED WORD
#typedef TCHAR UNSIGNED WORD
#else
#typedef LPCTSTR POINTER
#typedef LPTSTR POINTER
#typedef PCTSTR POINTER
#typedef PTSTR POINTER
#typedef TBYTE UNSIGNED BYTE
#typedef TCHAR UNSIGNED BYTE
#endif

// Windows Types

#typedef ATOM UNSIGNED WORD
#typedef BOOL INT
#typedef BOOLEAN BYTE
#typedef CHAR UNSIGNED BYTE
#typedef COLORREF UNSIGNED INT
#typedef DWORD UNSIGNED INT
#typedef DWORDLONG UNSIGNED INT64
#typedef DWORD_PTR ULONG_PTR
#typedef DWORD32 UNSIGNED INT
#typedef DWORD64 INT64
#typedef HACCEL INT
#typedef HANDLE INT
#typedef HBITMAP INT
#typedef HBRUSH INT
#typedef HCOLORSPACE INT
#typedef HCONV INT
#typedef HCONVLIST INT
#typedef HCURSOR INT
#typedef HDC INT
#typedef HDDEDATA INT
#typedef HDESK INT
#typedef HDROP INT
#typedef HDWP INT
#typedef HENHMETAFILE INT
#typedef HFILE INT
#typedef HFONT INT
#typedef HGDIOBJ INT
#typedef HGLOBAL INT
#typedef HHOOK INT
#typedef HICON INT
#typedef HIMAGELIST INT
#typedef HIMC INT
#typedef HINSTANCE INT
#typedef HKEY INT
#typedef HKL INT
#typedef HLOCAL INT
#typedef HMENU INT
#typedef HMETAFILE INT
#typedef HMODULE INT
#typedef HMONITOR INT
#typedef HPALETTE INT
#typedef HPEN INT
#typedef HRESULT INT
#typedef HRGN INT
#typedef HRSRC INT
#typedef HSZ INT
#typedef HWINSTA INT
#typedef HWND INT
#typedef INT32 INT
#typedef LANGID UNSIGNED WORD
#typedef LCID UNSIGNED INT
#typedef LCTYPE UNSIGNED INT
#typedef LGRPID UNSIGNED INT
#typedef LONG INT
#typedef LONGLONG INT64
#typedef LONG32 INT
#typedef LONG64 INT64
#typedef LPARAM LONG_PTR
#typedef LPBOOL POINTER
#typedef LPBYTE POINTER
#typedef LPCOLORREF POINTER
#typedef LPCRITICAL_SECTION POINTER
#typedef LPCSTR POINTER
#typedef LPCWSTR POINTER
#typedef LPCVOID POINTER
#typedef LPDWORD POINTER
#typedef LPHANDLE POINTER
#typedef LPINT POINTER
#typedef LPLONG POINTER
#typedef LPSTR POINTER
#typedef LPWORD POINTER
#typedef LPWSTR POINTER
#typedef LPVOID POINTER
#typedef LRESULT LONG_PTR
#typedef PBOOL POINTER
#typedef PBOOLEAN POINTER
#typedef PBYTE POINTER
#typedef PCHAR POINTER
#typedef PCRITICAL_SECTION POINTER
#typedef PCSTR POINTER
#typedef PCWSTR POINTER
#typedef PCWCH POINTER
#typedef PDWORD POINTER
#typedef PDWORDLONG POINTER
#typedef PDWORD_PTR POINTER
#typedef PDWORD32 POINTER
#typedef PDWORD64 POINTER
#typedef PFLOAT POINTER
#typedef PHANDLE POINTER
#typedef PHKEY POINTER
#typedef PINT POINTER
#typedef PINT_PTR POINTER
#typedef PINT32 POINTER
#typedef PINT64 POINTER
#typedef PLCID POINTER
#typedef PLONG POINTER
#typedef PLONGLONG POINTER
#typedef PLONG_PTR POINTER
#typedef PLONG32 POINTER
#typedef PLONG64 POINTER
#typedef PLUID POINTER
#typedef POINTER_64 INT64
#typedef POINTER_SIGNED POINTER
#typedef POINTER_UNSIGNED UNSIGNED POINTER
#typedef PSHORT POINTER
#typedef PSIZE_T POINTER
#typedef PSSIZE_T POINTER
#typedef PSTR POINTER
#typedef PSZ POINTER
#typedef PTBYTE POINTER
#typedef PTCHAR POINTER
#typedef PUCHAR POINTER
#typedef PUINT POINTER
#typedef PUINT_PTR POINTER
#typedef PUINT32 POINTER
#typedef PUINT64 POINTER
#typedef PULONG POINTER
#typedef PULONGLONG POINTER
#typedef PULONG_PTR POINTER
#typedef PULONG32 POINTER
#typedef PULONG64 POINTER
#typedef PUSHORT POINTER
#typedef PVOID POINTER
#typedef PWCHAR POINTER
#typedef PWORD POINTER
#typedef PWSTR POINTER
#typedef SC_HANDLE INT
#typedef SC_LOCK POINTER
#typedef SERVICE_STATUS_HANDLE INT
#typedef SHORT WORD
#typedef SIZE_T ULONG_PTR
#typedef SSIZE_T LONG_PTR
#typedef UCHAR UNSIGNED BYTE
#typedef UINT UNSIGNED INT
#typedef UINT32 UNSIGNED INT
#typedef UINT64 UNSIGNED INT64
#typedef ULONG UNSIGNED INT
#typedef ULONGLONG UNSIGNED INT64
#typedef ULONG32 UNSIGNED INT
#typedef ULONG64 UNSIGNED INT64
#typedef USHORT UNSIGNED WORD
#typedef USN INT64
#typedef WCHAR UNSIGNED WORD
#typedef WPARAM UINT_PTR

Steven Picard


ExMember001


kryton9

Why in the world would microsoft make so many types?

Is there a single type we could use in Aurora if we wanted that would cover all the existing types. Like a universal type that we could just use, with tons of system ram and smaller programs, it would be neat to be lazy, or is that something the compiler would have fits over and is that something only interpreted languages can offer?

Ionic Wind Support Team

You're not seeing the big picture ;).

The types are type-defined to the real sizes of byte, word, int and int64.  C is very strict with its type defines.  If you define a variable of type HMENU you can only use it for a handle to a menu.  So any parameter has to be defined as HMENU as well.  Even though I know it's an int, the compiler knows it's an int, etc.

It's designed to prevent coding errors and improve readability when used with C compilers.  Which would be fine and dandy if there wasn't a way to break the strict type checking rules.  Which leads to the stigma that C is harder to read than other languages.  type casting in C allows you to override the type checking and force a variable that's been defined as one type to be treated as another.

HANDLE h;
int w = (int)GetDesktopWindow();
(HMENU)h = GetMenu((HWND)w);

I've seen a lot of code like that over the years.  Usually from a programmer wanting to reuse variables.

Ionic Wind Support Team

kryton9

All I can say is YIKES. If I saw that I would just turn around and run the other way :)

Kale

Quote from: Paul Turley on August 13, 2006, 10:40:07 PM
HANDLE h;
int w = (int)GetDesktopWindow();
(HMENU)h = GetMenu((HWND)w);


I've seen a lot of code like that over the years.ÂÃ,  Usually from a programmer wanting to reuse variables.

They should be shot. ;)