After spending way too much time doing this manually, this idea came to be. I use this extraordinarily frequently, so thought someone else might one day have a use for it. The title pretty much sums it up; here's some notes:
-Automatically detects if typedef struct or typedef enum
-Types support automatic variable type changing and have the most common ones built in (e.g. DWORD = Long, LPSTR = String)
-Arrays are supported for types, both when defined by number var[10]->var(0 To 9) and by variable, var[MAX_PATH]->var(0 To (MAX_PATH - 1))
-Comments have the option to be included or removed
-Enums that don't have an = sign (sequential) are supported, both with and without an initial entry with =0 or =1
-Option for public or private
-Option to remove 'tag' in names
-Various automatic syntax corrections
Samples
Those two really show it all...
(the VB output is properly indented, can't see it here)
I might change this into an add-in that could do convert-on-paste or convert from the right click menu, if anyone is interested in that let me know.
NOTE: I believe the people who would use a tool like this would also not need extensive documentation of the code or e.g. not be ok with the only way to add type replacements being to add another line in a function... this isn't for beginners so don't be too harsh about the cryptic code :)
Also, I rely on VB to do things like correct the case of native data types (long isn't replaced with Long), and change &H0001 to &H1; it's not worth doing manually.
If anyone is interested I also have a utility that will turn a UUID into a IID_IWhatever function like the ones in mIID.bas in oleexp.
PS- Don't actually use that SMDATA type; I altered it to show features.
-Automatically detects if typedef struct or typedef enum
-Types support automatic variable type changing and have the most common ones built in (e.g. DWORD = Long, LPSTR = String)
-Arrays are supported for types, both when defined by number var[10]->var(0 To 9) and by variable, var[MAX_PATH]->var(0 To (MAX_PATH - 1))
-Comments have the option to be included or removed
-Enums that don't have an = sign (sequential) are supported, both with and without an initial entry with =0 or =1
-Option for public or private
-Option to remove 'tag' in names
-Various automatic syntax corrections
Samples
typedef enum _tagPSUACTION { PSU_DEFAULT = 1 // gets security URL and returns its domain. ,PSU_SECURITY_URL_ONLY // gets just the security URL } PSUACTION; |
Public Enum PSUACTION PSU_DEFAULT=1 ' gets security URL and returns its domain. PSU_SECURITY_URL_ONLY = 2 ' gets just the security URL End Enum |
typedef struct SMDATA { DWORD dwMask; // SMDM_* values DWORD dwFlags; // Not used long hmenu; // Static HMENU portion. HWND hwnd; // HWND owning the HMENU UINT uId; // Id of the item in the menu (-1 for menu itself) UINT uIdParent; // Id of the item spawning this menu UINT uIdAncestor[80]; // Id of the very top item in the chain of ShellFolders //IUnknown* punk; // IUnkown of the menuband long punk; //use pointer?? long pidlFolder;// pidl of the ShellFolder portion long pidlItem; // pidl of the item in the ShellFolder portion //IShellFolder* psf; // IShellFolder for the shell folder portion long psf; //use pointer?? WCHAR pvUserData[MAX_PATH]; // User defined Data associated with a pane. } SMDATA; |
Public Type SMDATA dwMask As Long ' SMDM_* values dwFlags As Long ' Not used hmenu As long ' Static HMENU portion. hwnd As Long ' HWND owning the HMENU uId As Long ' Id of the item in the menu (-1 for menu itself) uIdParent As Long ' Id of the item spawning this menu uIdAncestor(0 To 79) As Long ' Id of the very top item in the chain of ShellFolders 'IUnknown* punk; // IUnkown of the menuband punk As long 'use pointer?? pidlFolder As long ' pidl of the ShellFolder portion pidlItem As long ' pidl of the item in the ShellFolder portion 'IShellFolder* psf; // IShellFolder for the shell folder portion psf As long 'use pointer?? pvUserData(0 To (MAX_PATH - 1)) As Integer ' User defined Data associated with a pane. End Type |
Those two really show it all...
(the VB output is properly indented, can't see it here)
I might change this into an add-in that could do convert-on-paste or convert from the right click menu, if anyone is interested in that let me know.
NOTE: I believe the people who would use a tool like this would also not need extensive documentation of the code or e.g. not be ok with the only way to add type replacements being to add another line in a function... this isn't for beginners so don't be too harsh about the cryptic code :)
Also, I rely on VB to do things like correct the case of native data types (long isn't replaced with Long), and change &H0001 to &H1; it's not worth doing manually.
If anyone is interested I also have a utility that will turn a UUID into a IID_IWhatever function like the ones in mIID.bas in oleexp.
PS- Don't actually use that SMDATA type; I altered it to show features.