2 * genguid utility for WINE and ReactOS
4 * Copyright 2003 Jonathan Wilson
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 int main(int argc
, char *argv
[])
26 GUID m_guid
= GUID_NULL
;
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");
42 if ((arg
> 5) || (arg
<= 0)) {
43 printf("invalid argument\n");
46 if (CoInitialize(NULL
) != S_OK
)
48 printf("Unable to initialize OLE libraries\n");
51 result
= CoCreateGuid(&m_guid
);
53 printf("Unable to create GUID\n");
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";
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";
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";
68 strfmt
= "{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}\r\n";
71 strfmt
= "%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X\r\n";
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]);