Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Windows Data Types lookup tool


  • Please log in to reply
4 replies to this topic
PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
I found an interesting page in MSDN, listing all (more or less) the data types defined in Windows API.
I thought it would be useful to quickly lookup a type seen in MSDN (structure fields, function parameters...), so I copied it, put in a text file, edited it a bit, sorted by type size, etc.
I could just use the Find function of my text editor, but it wouldn't have been fun, so I wrote a little GUI to ease such lookups.
For once, the listing isn't so big, so I paste it here, but you can download it: WindowsDataTypes.ahk, reading the file WindowsDataTypes.txt.
/*
WindowsDataTypes.ahk

A program to look up a data type defined in the Windows API,
to give information on it, including the AutoHotkey type to use in DllCall.

// by Philippe Lhoste <PhiLho(a)GMX.net> http://Phi.Lho.free.fr
// File/Project history:
 1.00.000 -- 2006/08/25 (PL) -- Creation.
*/
/* Copyright notice: See the PhiLhoSoftLicence.txt file for details.
This file is distributed under the zlib/libpng license.
Copyright (c) 2006 Philippe Lhoste / PhiLhoSoft
*/

#SingleInstance Force
#NoEnv

definitionFile = WindowsDataTypes.txt

#equiv?V0 = N/A
#equiv?S8 = Char
#equiv?U8 = UChar
#equiv?S16 = Short
#equiv?U16 = UShort
#equiv?S32 = Int
#equiv?U32 = UInt
#equiv?F32 = Float
#equiv?S64 = Int64
#equiv?U64 = UInt64
#equiv?D64 = Double


Gui Add, Edit, x10 y10 w150 vsearchedString gIncrementalSearch
Gui Add, ListBox, x10 y40 w150 h350 vtypeList gClickInList +Sort
Gui Add, Text, x170 y18 w100, Equivalence
Gui Add, Edit, x280 y15 w50 vequivalence
Gui Add, Text, x170 y58 w100, AutoHotkey Format
Gui Add, Edit, x280 y55 w50 vahkFormat
Gui Add, Text, x170 y98 w100, Description
Gui Add, Edit, x280 y95 w200 h90 vdescription
Gui Add, Text, x170 y206 w100, Include file where it is defined
Gui Add, Edit, x280 y206 w150 vincludeFile
Gui Add, Text, x170 y248 w100, Definition
Gui Add, Edit, x280 y245 w200 h120 vdefinition
Gui, Add, StatusBar
Gui Show, , Windows Data Types
Gosub FillListBox
Return

FillListBox:
	GuiControl -Redraw, typeList
	defNb := 0
	Loop Read, %definitionFile%
	{
		StringLeft fc, A_LoopReadLine, 1
		If (fc = ";")
			Continue	; Comment
		If (fc = "")
		{
			; Start of a definition
			defPos := 0
			defNb++
			Continue
		}
		defPos++
		If (defPos = 1)
		{
			definitions%defNb%?typeName := A_LoopReadLine
			GuiControl, , typeList, %A_LoopReadLine%
		}
		Else If (defPos = 2)
		{
			definitions%defNb%?equivalence := A_LoopReadLine
		}
		Else If (defPos = 3)
		{
			definitions%defNb%?description := A_LoopReadLine
		}
		Else If (defPos = 4)
		{
			definitions%defNb%?includeFile := A_LoopReadLine
		}
		Else If (defPos > 4)
		{
			definitions%defNb%?definition := definitions%defNb%?definition . A_LoopReadLine . "`n"
		}
	}
	SB_SetText(defNb . " definitions found!")
	GuiControl +Redraw, typeList
Return

IncrementalSearch:
	Gui Submit, NoHide
	len := StrLen(searchedString)
	itemNb := 0
	Loop %defNb%
	{
		StringLeft part, definitions%A_Index%?typeName, len
		If (part = searchedString)
		{
			itemNb := A_Index
			Break
		}
	}

	If (itemNb != 0)
	{
		part := definitions%itemNb%?typeName
		GuiControl Choose, typeList, %part%
		Goto ClickInList
	}
Return

ClickInList:
	GuiControlGet type, , typeList
	Loop %defNb%
	{
		If (type = definitions%A_Index%?typeName)
		{
			equiv := definitions%A_Index%?equivalence
			GuiControl, , equivalence, %equiv%
			ahkType := #equiv?%equiv%
			GuiControl, , ahkFormat, %ahkType%
			t := definitions%A_Index%?description
			GuiControl, , description, %t%
			t := definitions%A_Index%?includeFile
			GuiControl, , includeFile, %t%
			t := definitions%A_Index%?definition
			GuiControl, , definition, %t%
			Break
		}
	}
Return

GuiEscape:
GuiClose:
ExitApp
Excerpt of data:
VOID
V0
Any type.
WinNT.h
#define VOID void

CHAR
S8
8-bit Windows (ANSI) character.
WinNT.h
typedef char CHAR;

TCHAR
S8
A WCHAR if UNICODE is defined, a CHAR otherwise.
WinNT.h
#ifdef UNICODE
 typedef WCHAR TCHAR;
#else
 typedef char TCHAR;
#endif

UCHAR
U8
Unsigned CHAR.
WinDef.h
typedef unsigned char UCHAR;

BYTE
U8
Byte (8 bits).
WinDef.h
typedef unsigned char BYTE;
Note that this program can be easily adapted to lookup any kind of information based on some keyword.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Just few words on usage:
Type or paste the Windows type name in the edit box above the list box to find it in the list.
It is autoincremental: just type the first letters to jump to type.
There is a glitch (some might call it a bug...): I let the ListBox to do the sorting, but I still search in the original order, so when searching, the selection can not be the first one in the alpabetical order, ie. if I type UL, ULONG32 is selected even as ULONG is before it.
To be more precise, either I should sort before adding to the list box, or I should take the strings from the list box itself (but alas, it takes some work as I see no way to take a string from its index. There is only commands to take the selected string). Not worth the effort.

The Equivalence field is personal, it just shows the type (signed/unsigned) and the size (in bits) of the type. There might be errors here...
I convert this Equivalence to the AutoHotkey format.
The edit fields are not read-only, but editing them does nothing...

That's most of it, if you think of some improvement, let me know.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006
Very helpful my guru friend,


small suggestion: POST THE TXT AS A QUOTE IN THE THREAD... ( would do it myself, but it's your thread... and such...)


one reason WHY TO DO THIS... when was searching the forums for help using a particular MS type name.. it did NOT show up... but it IS in the txt file... so by posting the (it's not that long) file right here.... searchers in the forum for that info... CAN FIND IT....



and it sure is helpful!

thanks!
Joyce Jamce

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Good idea, but if this is for referencing only, I will just put the type names, no need for extra info that will just bloat the topic.

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


Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

imfirefly
  • Members
  • 3 posts
  • Last active: Jan 05 2015 03:18 PM
  • Joined: 29 Aug 2012
Thank you very much!

But the download link is borken. Please fix the download problem. Thanks again!