home *** CD-ROM | disk | FTP | other *** search
- /*
- * @(#)Registry.cpp 1.2 97/05/13
- *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
- *
- * This software is the confidential and proprietary information of Sun
- * Microsystems, Inc. ("Confidential Information"). You shall not
- * disclose such Confidential Information and shall use it only in
- * accordance with the terms of the license agreement you entered into
- * with Sun.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
- * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
- * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
- * THIS SOFTWARE OR ITS DERIVATIVES.
- *
- * CopyrightVersion 1.0
- */
-
- #include <stdio.h>
- #include <wtypes.h>
- #include <winnt.h>
- #include <winreg.h>
- #include <winbase.h>
-
- extern char *CLASSPATH, *MAINCLASS, *PATH, *PROPFILE;
-
- int getRegistryValues() {
- HKEY mainKey;
- DWORD res;
- long retval;
-
- retval = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
- "SOFTWARE\\JavaSoft\\JSDK",
- 0,
- "JSDK",
- REG_OPTION_NON_VOLATILE,
- KEY_ALL_ACCESS,
- NULL,
- &mainKey,
- &res);
- if (retval != ERROR_SUCCESS) {
- char bbuf[1024];
- unsigned long bbb = 1024;
- unsigned long typeis = FORMAT_MESSAGE_FROM_HMODULE;
- memset(bbuf, 0, 1024);
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
- &typeis,
- GetLastError(),
- 0,
- bbuf,
- bbb,
- NULL);
-
- return 0;
- }
-
- char keybuf[16], valuebuf[1024];
- unsigned long keylen = 16, valuelen = 1024, typevar = REG_SZ;
- int iter = 0;
- while ((retval = RegEnumValue(mainKey,
- iter++,
- keybuf,
- &keylen,
- NULL,
- &typevar,
- (unsigned char *)valuebuf,
- &valuelen)) != ERROR_NO_MORE_ITEMS) {
- if (!strcmp(keybuf, "ClassPath")) {
- CLASSPATH = strdup(valuebuf);
- } else if (!strcmp(keybuf, "MainClass")) {
- MAINCLASS = strdup(valuebuf);
- } else if (!strcmp(keybuf, "PropFile")) {
- PROPFILE = strdup(valuebuf);
- } else if (!strcmp(keybuf, "Path")) {
- PATH = strdup(valuebuf);
- }
- keylen = 16;
- valuelen = 1024;
- }
- return 1;
- }
-