|
-
May 20th, 2012, 05:28 PM
#10
Frenzied Member
Re: Variable uses an automation type not supported in Visual Basic
Here's the last one I wrote (some years ago, I might add) that bound an unmanaged and non-COM DLL to COM via IDL so that it is useable in VB6. You should be able to figure it all out from there,
Code:
library Win32API {
importlib ("stdole2.tlb");
module CONSTANTS {
[
helpstring ("Constants used by this type library")
]
const long REGISTRY_MAXIMUM_VALUE_SIZE_BYTES =254;
const long ENVIRONMENT_MAXIMUM_BUFFER_SIZE_BYTES =254;
const long MAXIMUM_CLASS_ENUMERATION =512;
const long MAX_WSADescription =256;
const long MAX_WSASYSStatus =128;
const long HEAP_ZERO_MEMORY =0x8;
const long STATUS_NO_MEMORY =0xc0000017;
const long STATUS_ACCESS_VIOLATION =0xc0000005;
const long KEY_WOW64_64KEY =0x0100; // this is not good, needed for WOW services
const long LOGPIXELSY =0x5a;
const long MM_ISOTROPIC =7;
}
typedef
[
uuid(9C8CC2E4-D61D-4653-AF22-4C9EEE2966A4),
helpstring("Event log types")
]
enum WIN32_EVENTLOG_TYPES {
EVENTLOG_SUCCESS =0x0,
EVENTLOG_ERROR_TYPE =0x1,
EVENTLOG_WARNING_TYPE =0x2,
EVENTLOG_INFORMATION_TYPE =0x4,
EVENTLOG_AUDIT_SUCCESS =0x8,
EVENTLOG_AUDIT_FAILURE =0x10
} WIN32_EVENTLOG_TYPES;
typedef
[
uuid(8a06358e-70b7-44ce-a2d0-f41eb668ae28),
helpstring ("Win32 Registry Root Keys")
]
enum WIN32_REG_ROOT_KEYS {
HKEY_CLASSES_ROOT =0x80000000,
HKEY_CURRENT_USER =0x80000001,
HKEY_LOCAL_MACHINE =0x80000002,
HKEY_USERS =0x80000003,
HKEY_PERFORMANCE_DATA =0x80000004,
HKEY_CURRENT_CONFIG =0x80000005,
HKEY_DYN_DATA =0x80000006
} WIN32_REG_ROOT_KEYS;
typedef
[
uuid(81c41f67-c620-4a48-aaa3-24b2c8b8bfca),
helpstring ("Win32 Registry Open/Create Options")
]
enum WIN32_REG_OPENCREATE_OPTIONS {
REG_OPTION_RESERVED =0x0,
REG_OPTION_NON_VOLATILE =0x0,
REG_OPTION_VOLATILE =0x1,
REG_OPTION_CREATE_LINK =0x2,
REG_OPTION_BACKUP_RESTORE =0x4,
REG_OPTION_OPEN_LINK =0x8
} WIN32_REG_OPENCREATE_OPTIONS;
typedef
[
uuid(ac9d6a1e-2950-45e8-9e5b-9f84a154b0f8),
helpstring("Win32 Specific Access Rights")
]
enum WIN32_REG_ACCESS_RIGHTS {
KEY_QUERY_VALUE =0x1,
KEY_SET_VALUE =0x2,
KEY_CREATE_SUB_KEY =0x4,
KEY_ENUMERATE_SUB_KEYS =0x8,
KEY_NOTIFY =0x10,
KEY_CREATE_LINK =0x20
} WIN32_REG_ACCESS_RIGHTS;
typedef
[
uuid(e01b832f-65ff-4e45-838d-9033e5075acd),
helpstring ("Win32 Registry Datatypes")
]
enum WIN32_REG_DATATYPES {
REG_BINARY =0x3,
REG_DWORD =0x4,
REG_DWORD_BIG_ENDIAN =0x5,
REG_DWORD_LITTLE_ENDIAN =0x4,
REG_EXPAND_SZ =0x2,
REG_LINK =0x6,
REG_MULTI_SZ =0x7,
REG_NONE =0x0,
REG_RESOURCE_LIST =0x8,
REG_SZ =0x1
} WIN32_REG_DATATYPES;
typedef
[
uuid(BCF4A54B-03B6-416E-87AD-58D13C5091B6),
helpstring("lDispostion return values")
]
enum WIN32_REG_DISPOSITION {
REG_CREATED_NEW_KEY =0x1,
REG_OPENED_EXISTING_KEY =0x2
} WIN32_REG_DISPOSITION;
typedef
[
uuid(1944A5CC-0462-49F7-8673-3B601645A638),
helpstring("Draw Text Constants")
]
enum WIN32_DRAW_TEXT {
DT_BOTTOM =0x8,
DT_CALCRECT =0x400,
DT_CENTER =0x1,
DT_EXPANDTABS =0x40,
DT_EXTERNALLEADINEDGER =0x200,
DT_LEFT =0x0,
DT_NOCLIP =0x100,
DT_NOPREFIX =0x800,
DT_RIGHT =0x2,
DT_SINGLELINE =0x20,
DT_TABSTOP =0x80,
DT_TOP =0x0,
DT_VCENTER =0x4,
DT_WORDBREAK =0x10,
DT_RTLREADING =0x20000
} WIN32_DRAW_TEXT;
typedef
[
uuid(F0995818-43C1-4453-8DB3-D4020ADAFA14),
helpstring("Locale Constants")
]
enum WIN32_LOCALE {
LOCALE_SCURRENCY =0x14,
LOCALE_SINTLSYMBOL =0x15,
LOCALE_IDIGITS =0x11,
LOCALE_ILZERO =0x12,
LOCALE_INEGNUMBER =0x1010,
LOCALE_SGROUPING =0x10,
LOCALE_SDECIMAL =0xe,
LOCALE_STHOUSAND =0xf,
LOCALE_INEGCURR =0x1c,
LOCALE_SMONDECIMALSEP =0x16,
LOCALE_SMONTHOUSANDSEP =0x17,
LOCALE_ICURRENCY =0x1b
} WIN32_LOCALE;
///////////////////////////////////////////////
// WIN32 Structs used in this type library ...
///////////////////////////////////////////////
struct FILETIME {
long dwLowDateTime;
long dwHighDatetime;
};
struct SAFEARRAY1D {
short cDims;
short fFeatures;
long cbElements;
long cLocks;
long pvData;
long cElement;
long lLBound;
};
struct SAFEARRAYBOUNDS {
long LBound;
long UBound;
};
struct ICMP_OPTIONS {
unsigned char Ttl;
unsigned char Tos;
unsigned char Flags;
unsigned char OptionsSize;
long OptionsData;
};
struct ICMP_ECHO_REPLY {
long Address;
long Status;
long RoundTripTime;
short Datasize;
short Reserved;
long DataPointer;
struct ICMP_OPTIONS Options;
BSTR Data; //initialise to length 250 before using
};
struct WSADATA {
short wVersion;
short wHighVersion;
SAFEARRAY (unsigned char) szDescription; //initialise to MAX_WSADESCRIPTION
SAFEARRAY (unsigned char) szSystemStatus;//initialise to MAX_WSASYSStatus
long wMaxSockets;
long wMaxUDPDG;
long dwVendor;
};
struct HOSTENT {
long hName;
long hAliases;
short hAddrType;
short hLen;
long hAddrList;
};
struct DOCINFO {
long pDocName;
long pOutputFile;
long pDatatype;
};
struct POINTAPI {
long x;
long y;
};
struct SIZE {
long cx;
long cy;
};
struct RECT {
long Left;
long Top;
long Right;
long Bottom;
};
struct LOGFONT {
long lfHeight;
long lfWidth;
long lfEscapment;
long lfOrientation;
long lfWeight;
byte lfItalic;
byte lfUnderline;
byte lfStrikeOut;
byte lfCharSet;
byte lfOutPrecision;
byte lfClipPrecision;
byte lfQuality;
byte lfPitchAndFamily;
long plfFacename;
};
struct DRAWTEXTPARAMS {
long cbSize;
long iTabLength;
long iLeftMargin;
long iRightMargin;
long uiLengthDrawn;
};
struct NUMBERFMT {
long NumDigits;
long LeadingZero;
long Grouping;
long lpDecimalSep;
long lpThousandSep;
long NegativeOrder;
};
struct CURRENCYFMT {
long NumDigits;
long LeadingZero;
long Grouping;
long lpDecimalSep;
long lpThousandSep;
long NegativeOrder;
long PositiveOrder;
long lpCurrencySymbol;
};
struct SYSTEMTIME {
short wYear;
short wMonth;
short wDayOfWeek;
short wDay;
short wHour;
short wMinute;
short wSecond;
short wMilliseconds;
};
[
dllname("kernel32.dll"),
helpstring ("Kernel32 DLL Binding")
]
module Win32_Kernel32 {
[
entry ("RtlMoveMemory"),
helpstring ("The ubiquitous CopyMemory")
]
void _stdcall CopyMemory ([in] void* Destination, [in] void* Source, [in] int Length);
[
entry ("RtlZeroMemory"),
helpstring ("Fills a block of memory with zeros")
]
void _stdcall ZeroMemory ([in] void* Destination, [in] int Length);
[
entry("GetComputerNameW"),
helpstring("Retrieves the NetBIOS name of the local computer")
]
VARIANT_BOOL _stdcall GetComputerName ([in] long lpBuffer, [in,out,ref] long* lpnSize);
[
entry("HeapUnlock"),
helpstring("Releases ownership of the critical section object, or lock, that is associated with a specified heap")
]
long _stdcall HeapUnlock ([in] long hHeap);
[
entry("HeapLock"),
helpstring ("Attempts to acquire the critical section object, or lock, that is associated with a specified heap")
]
long _stdcall HeapLock ([in] long hHeap);
[
entry("HeapFree"),
helpstring ("Frees a memory block allocated from a heap by the HeapAlloc or HeapReAlloc function")
]
long _stdcall HeapFree ([in] long hHeap, [in] long dwFlags, [in,out] void* lpMem);
[
entry("HeapAlloc"),
helpstring ("Allocates a block of memory from a heap. The allocated memory is not movable")
]
long _stdcall HeapAlloc ([in] long hHeap, [in] long dwFlags, [in] long dwBytes);
[
entry("HeapCreate"),
helpstring ("Creates a private heap object that can be used by the calling process. The function reserves space in the virtual address space of the process and allocates physical storage for a specified initial portion of this block")
]
long _stdcall HeapCreate ([in] long flOptions, [in] long dwInitialSize, [in] long dwMaximumSize);
[
entry("HeapDestroy"),
helpstring("Destroys the specified heap object. It decommits and releases all the pages of a private heap object, and it invalidates the handle to the heap")
]
long _stdcall HeapDestroy ([in] long hHeap);
[
entry("HeapReAlloc"),
helpstring("Reallocates a block of memory from a heap. This function enables you to resize a memory block and change other memory block properties. The allocated memory is not movable")
]
long _stdcall HeapReAlloc ([in] long hHeap, [in] long dwFlags, [in] long lpMem, [in] long dwBytes);
[
entry("MulDiv"),
helpstring("Multiplies two 32-bit values and then divides the 64-bit result by a third 32-bit value")
]
long _stdcall MulDiv ([in] long nNumber, [in] long nNumerator, [in] long nDenominator);
[
entry("GetLocaleInfoW"),
helpstring("Retrieves information about a locale specified by identifier")
]
short _stdcall GetLocaleInfo ([in] long LCId, [in] long LCType, [in] long lpData, [in] short cchData);
[
entry("GetNumberFormatW"),
helpstring ("Formats a number string as a number string customized for a specified locale")
]
long _stdcall GetNumberFormat ([in] long Locale, [in] long dwFlags, [in] long lpValue, [in] struct NUMBERFMT lpFormat, [in] long lpNumberStr, [in] long cchNumber);
[
entry("IsValidLocale"),
helpstring ("Applies a validity test to a locale identifier")
]
VARIANT_BOOL _stdcall IsValidLocale ([in] long Locale, [in] long dwFlags);
[
entry("GetCurrencyFormatW"),
helpstring ("Formats a number string as a currency string for a locale specified by identifier")
]
long _stdcall GetCurrencyFormat ([in] long Locale, [in] long dwFlags, [in] long lpValue, [in] struct CURRENCYFMT lpFormat, [in] long lpCurrencyStr, [in] long cchCurrency);
[
entry("GetDateFormatW"),
helpstring ("Formats a number string as a date string for a locale specified by identifier")
]
long _stdcall GetDateFormat ([in] long Locale, [in] long dwFlags, [in] struct SYSTEMTIME lpDate, [in] long lpFormat, [in] long lpDateStr, [in] long cchDate);
[
entry("GetTimeFormatW"),
helpstring ("Formats a number string as a date string for a locale specified by identifier")
]
long _stdcall GetTimeFormat ([in] long Locale, [in] long dwFlags, [in] struct SYSTEMTIME lpTime, [in] long lpFormat, [in] long lpTimeStr, [in] long cchTime);
}
[
dllname("advapi32.dll"),
helpstring ("AdvAPI32 DLL Binding")
]
module Win32_AdvAPI32 {
[
entry("RegCreateKeyExW"),
helpstring("Creates the specified registry key")
]
long _stdcall RegCreateKeyEx ([in] long hKey, [in] long lpSubkey, [in] long Reserved, [in] long lpClass, [in] long dwOptions, [in] long samDesired, [in,out,ref] long* lpSecurityAttributes, [in,out,ref] long* phkResult, [in,out,ref] long* lpdwDisposition);
[
entry ("RegOpenKeyExW"),
helpstring ("Opens an existing registry key")
]
long _stdcall RegOpenKeyEx ([in] long hKey, [in] long pSubKey, [in] long ulOptions, [in] long samDesired, [out] long* phkResult);
[
entry ("RegCloseKey"),
helpstring ("Closes a key in the registry")
]
long _stdcall RegCloseKey ([in] long hKey);
[
entry ("RegQueryValueExW"),
helpstring ("Retrieves a value for a key")
]
long _stdcall RegQueryValueEx ([in] long hKey, [in] long lpValueName, [in] long lpReserved, [in,out,ref] long* lpType, [in] long lpData, [in,out,ref] long* lpcbData);
[
entry("RegEnumKeyExW"),
helpstring("Enumerates subkeys for the given key")
]
long _stdcall RegEnumKeyEx ([in] long hKey, [in] long dwIndex, [in] long lpName, [in,out] long* lpcbName, [in] long lpReserved, [in] long lpClass, [in,out] long* lpcbClass, [in,out] struct FILETIME* lpftLastWriteTime);
[
entry("RegEnumValueW"),
helpstring("Enumerates the values for the specified key")
]
long _stdcall RegEnumValue ([in] long hKey, [in] long dwIndex, [in] long lpValueName, [in,out] long* lpcbValueName, [in] long lpReserved, [in,out] long* lpType, [in] long lpData, [in,out] long* lpcbData);
[
entry("GetUserNameW"),
helpstring ("Retrieves Login name of thread owner")
]
long _stdcall GetUsername([in] long lpBuffer, [in,out] long* lpcbBuffer);
[
entry("IsTextUnicode"),
helpstring("Determines if a buffer is likely to contain a form of Unicode text")
]
long _stdcall IsTextUnicode ([in] long lpBuffer, [in] long cb, [in] long lpi);
[
entry("RegisterEventSourceW"),
helpstring("Retrieves a registered handle to the specified event log")
]
long _stdcall RegisterEventSource ([in] long lpUNCServerName, [in] long lpSourceName);
[
entry("DeregisterEventSource"),
helpstring("Closes the specified event long")
]
long _stdcall DeregisterEventSource ([in] long hEventLog);
[
entry("ReportEventW"),
helpstring("Writes an entry at the end of the specified event log")
]
VARIANT_BOOL _stdcall ReportEvent([in] long hEventLog, [in] int wType, [in] int wCategory, [in] long dwEventId, [in] long lpUserSid, [in] int wNumStrings, [in] long dwDataSize, [in,out,ref] long* plpStrings, [in,out,ref] long* lpRawData);
};
}
I don't think there's an example, here, but if you want to pass an enum in IDL you need to say so, so perhaps use [in] enum BlockPropertyId BlockProperty
"As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein
It's turtles! And it's all the way down
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|