Click to open or copy the GUIDGEN project files.
The GUIDGEN sample is a simple dialog-based Microsoft Foundation Class Library (MFC) application that can help you as you code ActiveX™ applications. GUIDGEN can be used to generate globally unique identifiers, or GUIDs, that identify classes, objects, and interfaces. GUIDGEN can be used in place of the Class ID Generator, which is a part of the OLE SDK.
To run GUIDGEN, just build the sample and run the application. The application will present a dialog box, which serves as its complete user interface.
The radio buttons in the "GUID Format" group box determine the format of the GUID the program will generate. The first format is designed to be used in invocations of MFC's IMPLEMENT_OLECREATE macro.
The second format generates a reference to the DEFINE_GUID macro.
The remaining formats are appropriate for statically allocated GUIDs and GUIDs included in registry entries or registry editor scripts.
Once you've selected the format for your GUID, you can copy it to the Clipboard with the Copy button. You can return to your editor and paste the GUID code into your application's source. When you need to generate a new GUID, press the New Guid button.
Aside from being a dialog-box based application, GUIDGEN also shows how MFC applications can paste text data to the Clipboard. The CGuidGenDlg::OnOK function in the GUIDGDLG.CPP file shows how OpenClipboard and SetClipboardData can be called to accomplish this task. The application also demonstrates calling the CoCreateGuid API to request a new GUID from the operating system. Look for this code in CGuidGenDlg::OnNewguid, which is also in the GUIDGDLG.CPP file.
This sample demonstrates the following keywords:
AfxGetApp; AfxMessageBox; CDC::DrawIcon; CDC::GetSafeHdc; CDialog::DoModal; CDialog::EndDialog; CDialog::OnInitDialog; CDialog::OnOK; CMenu::AppendMenu; CRect::Height; CRect::Width; CString::Format; CString::GetLength; CString::IsEmpty; CString::LoadString; CWinApp::Enable3dControls; CWinApp::ExitInstance; CWinApp::InitInstance; CWinApp::SetRegistryKey; CWnd::CenterWindow; CWnd::DoDataExchange; CWnd::GetClientRect; CWnd::GetParent; CWnd::GetSystemMenu; CWnd::IsIconic; CWnd::OnPaint; CWnd::OnQueryDragIcon; CWnd::OnSysCommand; CWnd::OpenClipboard; CWnd::SendMessage; CWnd::SetDlgItemText; CWnd::UpdateData; CloseClipboard; CoInitialize; CoUninitialize; EmptyClipboard; GetForegroundWindow; GetProfileInt; GetSystemMetrics; GlobalAlloc; GlobalLock; GlobalUnlock; LoadIcon; SetClipboardData; memcpy