The R Project SVN R

Rev

Rev 38882 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 38882 Rev 83695
Line 1... Line 1...
1
#define _OLEAUT32_
1
#define _OLEAUT32_
2
 
2
 
3
#include <stdio.h>
3
#include <stdio.h>
-
 
4
#include <stdlib.h>
-
 
5
#include <objbase.h>
4
#include <unknwn.h>
6
#include <unknwn.h>
5
 
7
 
6
GUID guid;
-
 
7
WORD* wstrGUID[100];
-
 
8
char strGUID[100];
-
 
9
int count, i;
-
 
10
 
-
 
11
int main (int argc, char* argv[]) 
8
int main (int argc, char* argv[]) 
12
{
9
{
-
 
10
    GUID guid;
-
 
11
    LPOLESTR wstrGUID;
-
 
12
    char *strGUID;
-
 
13
    int count, i, res;
13
 
14
 
14
    if (argc != 2) {
15
    if (argc != 2) {
15
	fprintf (stderr, "SYNTAX: UUIDGEN <number-of-GUIDs-to-generate>\n");
16
	fprintf (stderr, "SYNTAX: UUIDGEN <number-of-GUIDs-to-generate>\n");
16
	return 1;
17
	return 1;
17
    }
18
    }
18
    count = atoi (argv[1]);
19
    count = atoi (argv[1]);
19
    for (i = 0; i < count; i++) {
20
    for (i = 0; i < count; i++) {
20
	CoCreateGuid (&guid);
21
	CoCreateGuid (&guid);
21
	StringFromCLSID (&guid, wstrGUID);
22
	StringFromCLSID (&guid, &wstrGUID);
-
 
23
	res = WideCharToMultiByte (CP_ACP, 0, wstrGUID, -1, NULL, 0, NULL, NULL);
-
 
24
	if (res > 0) {
-
 
25
	    strGUID = (char *) malloc(res);
-
 
26
	    if (!strGUID) {
-
 
27
		fprintf(stderr, "Out of memory.");
-
 
28
		return 2;
-
 
29
	    }
22
	WideCharToMultiByte (CP_ACP, 0, *wstrGUID, -1, strGUID, MAX_PATH, NULL, NULL);
30
	    WideCharToMultiByte (CP_ACP, 0, wstrGUID, -1, strGUID, res, NULL, NULL);
23
	strGUID[strlen(strGUID)-1] = '\0';
31
	    strGUID[strlen(strGUID)-1] = '\0'; /* erase } */
24
	printf ("%s\n", strGUID+1);
32
	    printf ("%s\n", strGUID+1);
-
 
33
	    free(strGUID);
-
 
34
	}
-
 
35
	CoTaskMemFree (wstrGUID);
25
    }
36
    }
26
    return 0;
37
    return 0;
27
}
38
}