convert string like
{ef636391-f343-11d0-9477-00c04fd36226}
to
const CLSID CLSID_X = {0xEF636391,0xF343,0x11D0,0x94,0x77,0x00,0xC0,0x4F,0xD3,0x62,0x26};
or CLSID_X GUID <0EF636391H,0F343H,011D0H,<094H,077H,000H,0C0H,04FH,0D3H,062H,026H>>
with OLE functions.
void MakeCLSID(GUID guid, TCHAR *szGUID)
{
wsprintf(szGUID,
TEXT("const CLSID CLSID_X = {0x%08X,0x%04X,0x%04X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X};"),
guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
}
void Convert(HWND hwndDlg)
{
int nLen;
TCHAR szText[255], szTmp[255];
if ((nLen = GetDlgItemText(hwndDlg,4001,szText,sizeof(szText))) > 0) {
GUID guid;
szTmp[0] = 0;
if (!CLSIDFromProgID(szText, &guid)) {
MakeCLSID(guid, szTmp);
}
if (szText[0] == '{' && szText[nLen-1] == '}') {
if (!CLSIDFromString(szText, &guid)) {
MakeCLSID(guid, szTmp);
}
}
SetDlgItemText(hwndDlg, 4002, szTmp);
}
}
Updatevoid Convert(HWND hwndDlg)
{
int nLen;
TCHAR *pText, szText[255], szTmp[255];
if ((nLen = GetDlgItemText(hwndDlg,4001,&szText[1],sizeof(szText)-1)) > 0) {
GUID guid;
szTmp[0] = 0;
if (nLen == 36 && szText[1] != '{'
&& szText[9] == '-' && szText[14] == '-'
&& szText[19] == '-' && szText[24] == '-') {
szText[0] = '{';
szText[nLen+1] = '}';
szText[nLen+2] = 0;
pText = szText;
nLen += 2;
}
else {
pText = &szText[1];
szText[0] = ' ';
}
if (!CLSIDFromProgID(pText, &guid)) {
MakeCLSID(guid, szTmp);
}
if (*pText == '{' && *(pText+nLen-1) == '}') {
if (!CLSIDFromString(pText, &guid)) {
MakeCLSID(guid, szTmp);
}
}
if (*pText == '\"' && *(pText+nLen-1) == '\"') {
*pText = '{';
*(pText+nLen-1) = '}';
if (!CLSIDFromString(pText, &guid)) {
MakeCLSID(guid, szTmp);
}
}
SetDlgItemText(hwndDlg, 4002, szTmp);
}
}
EDIT 2015-10-23 CLSIDConv2.zip support to poasm GUID