Mapping C++ data types mentioned in MSDN library
Posted: Wed Feb 03, 2010 10:45 am
I`m trying to write a small app which allows to create declarations for DLL functions from a header file.
Currently I`m concentrating on the definitions of functions as you can find them in the MSDN Library (http://msdn.microsoft.com/en-us/library/) in order to create libraries for windows DLLs like kernel.dll, user32.dll, advapi32.dll and so on. These definitions look like:
LONG WINAPI RegCreateKey(
__in HKEY hKey,
__in_opt LPCTSTR lpSubKey,
__out PHKEY phkResult
);
Now I need to map the C++ data types to FNX-Basic data types. I got so far for now, but know nearly nothing about C++.
`===============================================================================
`==
` FNX knows these types:
` BOOLEAN, BYTE, DOUBLE, INTEGER, LONG, SHORT, SINGLE, STRING, WORD
FUNCTION ConvertDataType(strIn AS STRING) AS STRING
SELECT CASE UCASE$(strIn)
`=========================================================================
` BOOLEAN
`=========================================================================
CASE "BOOL": Result="BOOLEAN"
`=========================================================================
` BYTE
`=========================================================================
CASE "BYTE": Result="BYTE"
CASE "LPBYTE": Result="BYTE"
`=========================================================================
` DOUBLE
`=========================================================================
` a C double variable takes eight bytes
`=========================================================================
` INTEGER
`=========================================================================
CASE "UINT": Result="INTEGER"
` DWORD: 4-Byte-Ganzzahl
` see http://msdn.microsoft.com/de-de/library/cc431203.aspx
CASE "DWORD": Result="INTEGER"
` probably an integer
CASE "LPDWORD": Result="INTEGER"
` integer as per example
CASE "HKEY": Result="INTEGER"
` probably an integer
CASE "PHKEY": Result="INTEGER"
`=========================================================================
` LONG (aka INTEGER)
`=========================================================================
` probably a long
CASE "LONG": Result="LONG"
` probably a long
CASE "PLONG": Result="LONG"
`=========================================================================
` STRING
`=========================================================================
` probably a string
CASE "LPTSTR": Result="STRING"
` LPCTSTR: Long Pointer to a Constant null-Terminated String
` see http://acronyms.thefreedictionary.com/LPCTSTR
CASE "LPCTSTR": Result="STRING"
`=========================================================================
` UNKNOWN
`=========================================================================
`CASE "PVOID": Result=""
`CASE "LPVOID": Result=""
`CASE "LPCVOID": Result=""
`CASE "HANDLE": Result=""
`CASE "LPSECURITY_ATTRIBUTES": Result=""
`CASE "PFILETIME": Result=""
`CASE "PVALENT": Result=""
`CASE "REGSAM": Result=""
CASE strIn: Result=strIn
Debug("data type `"+strIn+"` can not be converted")
END SELECT
END FUNCTION
I assume that the C++ data types mentioned here are self defined (wrapper) types cause they are all uppercase while native C++ would be lowercase, right?
Can anyone help me to map the remaining types or give me a hint where I can find an overview of the data types which are used here?
Finally: what does "WINAPI" in the function header mean? I have no clue!
Currently I`m concentrating on the definitions of functions as you can find them in the MSDN Library (http://msdn.microsoft.com/en-us/library/) in order to create libraries for windows DLLs like kernel.dll, user32.dll, advapi32.dll and so on. These definitions look like:
LONG WINAPI RegCreateKey(
__in HKEY hKey,
__in_opt LPCTSTR lpSubKey,
__out PHKEY phkResult
);
Now I need to map the C++ data types to FNX-Basic data types. I got so far for now, but know nearly nothing about C++.
`===============================================================================
`==
` FNX knows these types:
` BOOLEAN, BYTE, DOUBLE, INTEGER, LONG, SHORT, SINGLE, STRING, WORD
FUNCTION ConvertDataType(strIn AS STRING) AS STRING
SELECT CASE UCASE$(strIn)
`=========================================================================
` BOOLEAN
`=========================================================================
CASE "BOOL": Result="BOOLEAN"
`=========================================================================
` BYTE
`=========================================================================
CASE "BYTE": Result="BYTE"
CASE "LPBYTE": Result="BYTE"
`=========================================================================
` DOUBLE
`=========================================================================
` a C double variable takes eight bytes
`=========================================================================
` INTEGER
`=========================================================================
CASE "UINT": Result="INTEGER"
` DWORD: 4-Byte-Ganzzahl
` see http://msdn.microsoft.com/de-de/library/cc431203.aspx
CASE "DWORD": Result="INTEGER"
` probably an integer
CASE "LPDWORD": Result="INTEGER"
` integer as per example
CASE "HKEY": Result="INTEGER"
` probably an integer
CASE "PHKEY": Result="INTEGER"
`=========================================================================
` LONG (aka INTEGER)
`=========================================================================
` probably a long
CASE "LONG": Result="LONG"
` probably a long
CASE "PLONG": Result="LONG"
`=========================================================================
` STRING
`=========================================================================
` probably a string
CASE "LPTSTR": Result="STRING"
` LPCTSTR: Long Pointer to a Constant null-Terminated String
` see http://acronyms.thefreedictionary.com/LPCTSTR
CASE "LPCTSTR": Result="STRING"
`=========================================================================
` UNKNOWN
`=========================================================================
`CASE "PVOID": Result=""
`CASE "LPVOID": Result=""
`CASE "LPCVOID": Result=""
`CASE "HANDLE": Result=""
`CASE "LPSECURITY_ATTRIBUTES": Result=""
`CASE "PFILETIME": Result=""
`CASE "PVALENT": Result=""
`CASE "REGSAM": Result=""
CASE strIn: Result=strIn
Debug("data type `"+strIn+"` can not be converted")
END SELECT
END FUNCTION
I assume that the C++ data types mentioned here are self defined (wrapper) types cause they are all uppercase while native C++ would be lowercase, right?
Can anyone help me to map the remaining types or give me a hint where I can find an overview of the data types which are used here?
Finally: what does "WINAPI" in the function header mean? I have no clue!