#opt nowarnings 1 IMMDeviceCollection ppDevices int dwStateMask defDEVICE_STATE_ACTIVE0x00000001 defDEVICE_STATE_DISABLED0x00000002 defDEVICE_STATE_NOTPRESENT0x00000004 defDEVICE_STATE_UNPLUGGED0x00000008 defDEVICE_STATEMASK_ALL0x0000000F int stgmAccess PROPERTYKEY pk
pk.pid=6 GUID t=pk.fmtid IMMDeviceEnumerator en IPropertyStore pProps word w VARIANT v
;PKEY_Device_FriendlyName does not exist in Windows SDK headers. Exists DEVPKEY_Device_FriendlyName, and it works. ;C++ definition from SDK devpkey.h: ;DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); PROPERTYKEY pk.pid=14;memcpy&pk.fmtid uuidof("{a45c254e-df1c-4efd-8020-67d146a850e0}")sizeof(GUID)
1. In C++ need only #include <devpkey.h> and maybe add some library. And install Windows SDK. In QM need to find DEVPKEY_Device_FriendlyName definition in devpkey.h and convert to QM. Attached devpkey.h from Win10 SDK. In PROPERTYKEY definition we see that it consists of GUID and int. One of ways to fill a GUID is memcpy uuidof.
2. QM _create is a shorter way to call CoCreateInstance. The MSDN example uses CoCreateInstance only for pEnumerator.
3. C++ LPWSTR in QM is word*. It is a raw Unicode string (just pointer).
4. Converts from Unicode UTF16 to QM string format, probably UTF8.
1. In C++ need only #include <devpkey.h> and maybe add some library. And install Windows SDK. In QM need to find DEVPKEY_Device_FriendlyName definition in devpkey.h and convert to QM. Attached devpkey.h from Win10 SDK. In PROPERTYKEY definition we see that it consists of GUID and int. One of ways to fill a GUID is memcpy uuidof.
yes, i messed to format properly in GUID format
2. QM _create is a shorter way to call CoCreateInstance. The MSDN example uses CoCreateInstance only for pEnumerator.
OK
3. C++ LPWSTR in QM is word*. It is a raw Unicode string (just pointer).
Hmm, how was I to know..i lost an incredible time with this.....read 10x times documentation.
4. Converts from Unicode UTF16 to QM string format, probably UTF8.
in MSDN
IPropertyStore::GetValue method
Gets data for a specific property.
Syntax
how did you find that pwszVal was the one to pickup? (aside the fact you're az master in programming)
5. STGM_READ is not declared, but valid in macro. But I must declare
def DEVICE_STATE_ACTIVE 0x00000001
def DEVICE_STATE_DISABLED 0x00000002
def DEVICE_STATE_NOTPRESENT 0x00000004
def DEVICE_STATE_UNPLUGGED 0x00000008
def DEVICE_STATEMASK_ALL 0x0000000F
to have function working, and don't understand why.
3. To understand MSDN code examples need to have some C/C++ and Windows API knowledge and experience. Then you know what is LPWSTR, or can find in SDK headers, where it is defined as pointer to unsigned short, which is a 2-byte integer, in QM it is word.
4. I just looked in the example, not in function reference. pwszVal was there. In PROPVARIANT its type is word*, which implies that it probably is a UTF16 string. QM string format is not UTF16, need to convert.
5. Part of Windows API in QM is declared through WINAPI, and it includes STGM_READ. Read more in QM help topic "Declare reference file or macro".
yes, i understand...........Your converted function is invaluable for understanding things,
but, winapi is so heavy, i think i can try to only use declarations i need,..........but still, some C++ -> QM translation are hard to
find..
Example, what is QM for
type REFERENCE_TIME = %
i did find those ..
#define REFTIMES_PER_SEC 10000000 QM= def REFTIMES_PER_SEC 10000000
WINAPI contains this invalid declaration for C typedef. It is like comments, for your information. Cannot convert to a valid QM declaration because QM does not have typedef. In this case it means that it is the same as type 'long'. Here % is long type character, look in QM help topic "Variables".
If in C code you see REFERENCE_TIME x, in QM it is long x.