Yesterday there was a question to my quick tip for creating a GUID in the Delphi IDE asking how to creating a GUID programmatically like this in one's own program. This simple console program demonstrates creating a GUID using the Windows API function CoCreateGuid:
if CoCreateGuid(Uid) = S_OK then
One thing I noticed when writing this example is I didn't need to make a call to CoInitialize. The CoInitialize documentation states "Applications must initialize the COM library before they can call COM library functions other than CoGetMalloc and memory allocation functions." So all Co.* calls must be called after a call to CoInitialize except for CoGetMalloc. Interesting. Does anyone know the answer to this? I suspect the documentation is just wrong.
Update: I changed the code originally posted because I was relying on a unreleased RTL and VCL.