I have begin to test Aurora because I'm interested in a compiler that allows to use low-level COM more easily that my current development compiler.
After I got the code that calls CLSIDFromString working, I wanted to convert it in a function (see WINAPI_CLSIDFromString below), and cut and pasted the code. The new function didn't work properly. Finally, I discovered the problem: The function has an string parameter called psz and I also had this same variable declared inside the function.
sub WINAPI_CLSIDFromString(string psz), GUID
{
int hr;
GUID rclsid;
int nLen;
pointer pwcs;
string psz;
nLen = (len(psz) + 1) * 2;
pwcs = AllocHeap(nLen);
RtlZeroMemory(pwcs, nLen);
hr = MultiByteToWideChar(0, 0, psz, len(psz), pwcs, nLen);
hr = CLSIDFromString(pwcs, rclsid);
FreeHeap(pwcs);
return rclsid;
}
I think that the compiler must flag it as an error, with a message such "Duplicate variable name".
/*
Compile this program to run in a console window.
*/
struct GUID,1
{
unsigned int data1;
unsigned word data2;
unsigned word data3;
unsigned byte data4[8];
}
import void CoTaskMemFree(void *pv);
import int CLSIDFromString(unsigned word *lpsz, GUID *pclsid);
import int StringFromCLSID(GUID *rclsid, unsigned int *ppsz);
import int StringFromGUID2(GUID *rclsid, unsigned word *lpsz, int cchMax);
import int MultiByteToWideChar(
unsigned int CodePage, // code page
unsigned int dwFlags, // character-type options
unsigned byte *lpMultiByteStr, // string to map
int cbMultiByte, // number of bytes in string
unsigned word *lpWideCharStr, // wide-character buffer
int cchWideChar // size of buffer
);
import int WideCharToMultiByte(
unsigned int CodePage, // code page
unsigned int dwFlags, // performance and mapping flags
unsigned word *lpWideCharStr, // wide-character string
int cchWideChar, // number of chars in string.
unsigned byte *lpMultiByteStr, // buffer for new string
int cbMultiByte, // size of buffer
unsigned byte *lpDefaultChar, // default for unmappable chars
unsigned int *lpUsedDefaultChar // set when default char used
);
import void RtlZeroMemory(void *Destination, unsigned int Length);
global sub main()
{
GUID rclsid;
rclsid = WINAPI_CLSIDFromString("{148BD52A-A2AB-11CE-B11F-00AA00530503}");
print(WINAPI_StringFromGUID2(rclsid));
do{}until getkey() <> "";
return;
}
sub WINAPI_CLSIDFromString(string psz), GUID
{
int hr;
GUID rclsid;
int nLen;
pointer pwcs;
nLen = (len(psz) + 1) * 2;
pwcs = AllocHeap(nLen);
RtlZeroMemory(pwcs, nLen);
hr = MultiByteToWideChar(0, 0, psz, len(psz), pwcs, nLen);
hr = CLSIDFromString(pwcs, rclsid);
FreeHeap(pwcs);
return rclsid;
}
sub WINAPI_StringFromGUID2(GUID *rclsid), string
{
int hr;
string pwsz;
string psz;
hr = StringFromGUID2(rclsid, pwsz, 40);
if hr = 0 return "";
hr = WideCharToMultiByte(0, 0, pwsz, -1, psz, 255, 0, 0);
return psz;
}
JOSE !!
Great to see you over here!
I am a Aurora newbie as well so I'm not much help to you, but I know that your COM experience will certainly benefit Aurora development.
Hi Paul,
Glad to see you here! In fact, I'm not asking for help, but pointing to an issue with duplicate variable names.
I like the way in which COM support is being implemented in Aurora, with COM classes and interface pointers. It's exactly the approach that I have suggested to Bob without luck.
Fixed for the Alpha 3 update.
Just a small note of joy.
Paul S, Paul T and JosÃÆ'Ã,© on the same thread discussing a new programming tool, Aurora.
Woww :D
/Lasse
(Still stuck in Object-C)