[TUTO] Les types de données - API Win32

Informations pour bien débuter en PureBasic
Avatar de l’utilisateur
Flype
Messages : 2431
Inscription : jeu. 29/janv./2004 0:26
Localisation : Nantes

[TUTO] Les types de données - API Win32

Message par Flype »

Freak, co-auteur de PureBasic avait fait un fichier qui explique comment traduire les types données utilisés dans les API Microsoft en PureBasic.

Pour le moment c'est en anglais, mais c'est tellement pratique, que je le mets ici en attendant une prochaine traduction.

Original :
http://freak.purearea.net/help/wintypes.txt

Code : Tout sélectionner

; *****************************************************************
; *                                                               *
; *   How To use Windows API Types With PureBasic                 *
; *                                                               *
; *   by Timo Harter, known As Freak                              *
; *                                                               *
; *****************************************************************
; 
; 
; - Note, that there are a lot of Types in Windows, that can be replaced
;   by the same PB Value, mostly LONG. the reason that there are a lot of
;   different Types, is that there are different Types For different jobs,
;   but As you can see, they are all replaced by LONG.
; 
; - by String, NULL-terminated Strings are meant.
; 
; - Types are Not in alphabetical Order, use a Search Function, To find
;   what you need.
; 
; - Finally:  Feel the _Pure_ Power !!
; 
; *****************************************************************
; 
; 
; 
; Following are Windows Types, And the PB Types, you can use For them (For LONG, see further down)
; *****************************************************************
; 
; VOID              VOID means no Variable, a Function With VOID As argument has no argument.
; CONST             Constant, any of Type.
; UNSIGNED          UNSIGNED Attribute (use normal Type, And fill With HEX Values, get Results With StrU() )
; 
; bool Or BOOLEAN   #TRUE (1), Or #FALSE (0) - can BYTE, WORD And LONG
; FLOAT             FLOAT
; BYTE              BYTE
; SHORT Or WORD     WORD
; USHORT            UNSIGNED SHORT (use WORD, And fill it With HEX Values, For Results, use StrU() )
; Char              Character, use BYTE
; uChar             UNSIGNED CHAR (use BYTE, And StrU() Or HEX Values)
; WCHAR             16-bit Unicode Character, use WORD
; TBYTE             a WCHAR If Unicode is defined, a Char otherwise.
; TCHAR             a WCHAR If Unicode is defined, a Char otherwise.
; 
; 
; 
; Following are Windows Types, that can't be used directly from PB
; *****************************************************************
; 
; ATOM              ATOM Tables are Sytem-defined String Tables, there's no PB-Type for that.
; REGSAM            Security access mask For registry key, Not bound To a Type
; WINAPI            Calling convention For system functions, that's no Type
; CALLBACK          Calling convention For CALLBACK functions, also no Type
; CRITICAL_SECTION  Critical Section Variable, don't know of what Type
; Luid              Locally unique identifier. (DOUBLE Value) To be accessed only by functions, Not directly
; SIZE_T            the maximum number of Bytes To which a pointer can point. use For a count that must span the full range of a pointer.
; SSIZE_T           Signed SIZE_T.
; 
; 
; 
; Following are Windows Types, that can be replaced by LONG Type.
; *****************************************************************
; 
; DWORD
; DWORD32
; DWORD_PTR       (used For Pointers)
; INT 
; INT_PTR         (Pointers)
; INT32
; LONG
; LONG_PTR        (Pointers)
; LONG32
; 
; COLORREF        Color Format (RGB) (LONG With Value $000000 - $FFFFFF)
; lParam          message parameter, use LONG
; wParam          message parameter, use LONG
; LRESULT         Signed result of message processing, use LONG
; LANGID          Language identifier, use LONG
; LCID            Locale identifier, use LONG
; LCTYPE          Locale information Type, LONG
; 
; 
; 
; Following are Windows Types, that could be replaced by UNSIGNED LONG
; (use LONG, And fill them With HEX Values, For getting Results, use StrU() )
; *****************************************************************
; 
; UINT
; UINT_PTR   (For Pointers)
; UINT32
; ULONG
; ULONG_PTR  (For Pointers)
; ULONG32
; 
; 
; 
; Following are Windows Types, meaning DOUBLE (Not supported yet)
; *****************************************************************
; 
; DWORD64
; INT64
; LONG64
; LONGLONG
; UINT64    (UNSIGNED)
; ULONG64   (UNSIGNED)
; ULONGLONG (UNSIGNED)
; 
; 
; 
; Following are Handles (thay identify Windows, Bitmaps, etc.), they are always LONG
; *****************************************************************
; 
; HACCEL                 Handle To an accelerator table.
; Handle                 Handle To an object.
; hBitmap                Handle To a bitmap.
; HBRUSH                 Handle To a brush.
; hConv                  Handle To a dynamic Data exchange (DDE) conversation.
; hConvList              Handle To a DDE conversation list.
; hCursor                Handle To a cursor.
; hdc                    Handle To a device context (DC).
; HDDEDATA               Handle To DDE Data.
; HDESK                  Handle To a desktop.
; hDrop                  Handle To an Internal drop Structure.
; HDWP                   Handle To a deferred window Position Structure.
; hEnhMetaFile           Handle To an enhanced metafile.
; hFile                  Handle To a file opened by OpenFile, Not CreateFile.
; HFONT                  Handle To a font.
; HGDIOBJ                Handle To a GDI object.
; hGlobal                Handle To a Global memory block.
; HHOOK                  Handle To a hook.
; hIcon                  Handle To an icon.
; HIMAGELIST             Handle To an image list.
; HIMC                   Handle To input context.
; hInstance              Handle To an instance.
; HKEY                   Handle To a registry key.
; HKL                    input Locale identifier.
; HLOCAL                 Handle To a local memory block.
; hMenu                  Handle To a menu.
; HMETAFILE              Handle To a metafile.
; HMODULE                Handle To a module.
; HMONITOR               Handle To a display monitor.
; HPALETTE               Handle To a palette.
; HPEN                   Handle To a pen.
; HRGN                   Handle To a region.
; HRSRC                  Handle To a resource.
; hsz                    Handle To a DDE String.
; HWINSTA                Handle To a window station.
; hwnd                   Handle To a window.
; SC_HANDLE              Handle To a service Control manager database.
; SC_LOCK                Handle To a service Control manager database lock.
; SERVICE_STATUS_HANDLE  Handle To a service Status Value.
; 
; 
; 
; Following are Pointers (memory adresses To Structures/Variables), they are also LONG
; *****************************************************************
; 
; LPBOOL               pointer To a bool.
; LPBYTE               pointer To a BYTE.
; LPCOLORREF           pointer To a COLORREF Value.
; LPCRITICAL_SECTION   pointer To a CRITICAL_SECTION.
; LPCSTR               pointer To a Constant String.
; LPCTSTR              an LPCWSTR If Unicode is defined, an LPCSTR otherwise.
; LPCVOID              pointer To a Constant of any Type.
; LPCWSTR              pointer To a Constant String of 16-bit Unicode characters.
; LPDWORD              pointer To a DWORD.
; LPHANDLE             pointer To a Handle.
; LPINT                pointer To an INT.
; LPLONG               pointer To a LONG.
; lpStr                pointer To a String
; LPTSTR               an LPWSTR If Unicode is defined, an lpStr otherwise.
; LPVOID               pointer To any Type.
; LPWORD               pointer To a WORD.
; LPWSTR               pointer To a String of 16-bit Unicode characters.
; pbool                pointer To a bool.
; PBOOLEAN             pointer To a bool.
; PBYTE                pointer To a BYTE.
; PCHAR                pointer To a Char.
; PCRITICAL_SECTION    pointer To a CRITICAL_SECTION.
; PCSTR                pointer To a String
; PCTSTR               a PCWSTR If Unicode is defined, a PCSTR otherwise.
; PCWCH                pointer To a Constant WCHAR.
; PCWSTR               pointer To a Constant String of 16-bit Unicode characters.
; PDWORD               pointer To a DWORD.
; PFLOAT               pointer To a FLOAT.
; PHANDLE              pointer To a Handle.
; PHKEY                pointer To an HKEY.
; PINT                 pointer To an INT.
; PLCID                pointer To an LCID.
; PLONG                pointer To a LONG.
; PLUID                pointer To a Luid.
; POINTER_32           32-bit pointer.
; POINTER_64           64-bit pointer. On a 64-bit system, this is a native pointer. On a 32-bit system, this is a sign-extended 32-bit pointer.
; PSHORT               pointer To a SHORT.
; PSTR                 pointer To a String
; PTBYTE               pointer To a TBYTE.
; PTCHAR               pointer To a TCHAR.
; PTSTR                a PWSTR If Unicode is defined, a PSTR otherwise.
; PUCHAR               pointer To a uChar.
; PUINT                pointer To a UINT.
; PULONG               pointer To a ULONG.
; PUSHORT              pointer To a USHORT.
; PVOID                pointer To any Type.
; PWCHAR               pointer To a WCHAR.
; PWORD                pointer To a WORD.
; PWSTR                pointer To a String of 16-bit Unicode characters.
; 
; 
; *****************************************************************
nn a512
Messages : 7
Inscription : ven. 31/mars/2006 22:16

Message par nn a512 »

Code : Tout sélectionner

; DWORD64 -> Unsigned quad (use quad And fill them With HEX Values, For getting Results, use StrU())
; INT64 -> Quad
; LONG64 -> Quad
; LONGLONG -> Quad
; UINT64    (UNSIGNED) -> Unsigned quad
; ULONG64   (UNSIGNED)  -> Unsigned quad
; ULONGLONG (UNSIGNED) -> Unsigned quad

wolfjeremy
Messages : 1202
Inscription : sam. 31/déc./2005 23:52

Message par wolfjeremy »

Merci,

C'est vrai que parfois on gallere un peut quand on tombe sur un type qu'on ne connais pas.
Répondre