ReactOS 0.4.15-dev-8428-g6910fa6
genguid.c File Reference
#include <objbase.h>
#include <stdio.h>
Include dependency graph for genguid.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 24 of file genguid.c.

25{
26 GUID m_guid = GUID_NULL;
27 int arg;
29 char *strfmt = "";
30 if (argc < 2) {
31 printf("usage: %s n\n",argv[0]);
32 printf("n = format of output\n");
33 printf("values are:\n");
34 printf("1 = IMPLEMENT_OLECREATE defintion\n");
35 printf("2 = DEFINE_GUID definition\n");
36 printf("3 = static const GUID definition\n");
37 printf("4 = registry format\n");
38 printf("5 = uuidgen.exe format\n");
39 return 1;
40 }
41 arg = atoi(argv[1]);
42 if ((arg > 5) || (arg <= 0)) {
43 printf("invalid argument\n");
44 return 1;
45 }
46 if (CoInitialize(NULL) != S_OK)
47 {
48 printf("Unable to initialize OLE libraries\n");
49 return 1;
50 }
51 result = CoCreateGuid(&m_guid);
52 if (result != S_OK) {
53 printf("Unable to create GUID\n");
55 return 1;
56 }
57 switch (arg) {
58 case 1:
59 strfmt = "// {%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\nIMPLEMENT_OLECREATE(<<class>>, <<external_name>>, \r\n0x%lx, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x);\r\n";
60 break;
61 case 2:
62 strfmt = "// {%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\nDEFINE_GUID(<<name>>, \r\n0x%lx, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x);\r\n";
63 break;
64 case 3:
65 strfmt = "// {%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\nstatic const GUID <<name>> = \r\n{ 0x%lx, 0x%x, 0x%x, { 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x } };\r\n";
66 break;
67 case 4:
68 strfmt = "{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\n";
69 break;
70 case 5:
71 strfmt = "%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X\r\n";
72 break;
73 }
74 printf(strfmt,m_guid.Data1,m_guid.Data2,m_guid.Data3,m_guid.Data4[0],
75 m_guid.Data4[1],m_guid.Data4[2],m_guid.Data4[3],m_guid.Data4[4],m_guid.Data4[5],
76 m_guid.Data4[6],m_guid.Data4[7],m_guid.Data1,m_guid.Data2,m_guid.Data3,m_guid.Data4[0],
77 m_guid.Data4[1],m_guid.Data4[2],m_guid.Data4[3],m_guid.Data4[4],m_guid.Data4[5],
78 m_guid.Data4[6],m_guid.Data4[7]);
80 return 0;
81}
static int argc
Definition: ServiceArgs.c:12
#define NULL
Definition: types.h:112
HRESULT WINAPI CoCreateGuid(GUID *pguid)
Definition: compobj.c:2206
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define printf
Definition: freeldr.h:97
GLuint64EXT * result
Definition: glext.h:11304
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define S_OK
Definition: intsafe.h:52
#define GUID_NULL
Definition: ks.h:106
static void strfmt(const char *str, char *strout)
Definition: text.c:617
#define argv
Definition: mplay32.c:18
void * arg
Definition: msvc.h:10