Use SearchPath in regedit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Windows, regedit will use SearchPath to find where the .reg file specified on the command line is located (or maybe it uses OpenFile directly). Some installers even rely on this!!!


Changelog:


* programs/regedit/regedit.c

Francois Gouget <fgouget@xxxxxxxxxxxxxxx>

Do a SearchPath before opening the file to improve compatibility with the native regedit.

--
Francois Gouget
fgouget@xxxxxxxxxxxxxxx

Index: programs/regedit/regedit.c
===================================================================
RCS file: /home/cvs/wine/programs/regedit/regedit.c,v
retrieving revision 1.9
diff -u -r1.9 regedit.c
--- programs/regedit/regedit.c	8 Dec 2003 22:48:07 -0000	1.9
+++ programs/regedit/regedit.c	12 Jan 2004 18:59:33 -0000
@@ -168,14 +168,33 @@
             }
 
             while(filename[0]) {
-                reg_file = fopen(filename, "r");
-                if (reg_file) {
-                    processRegLines(reg_file, doSetValue);
-                } else {
+                char* realname = NULL;
+                int size;
+                size=SearchPath(NULL,filename,NULL,0,NULL,NULL);
+                if (size>0)
+                {
+                    realname=HeapAlloc(GetProcessHeap(),0,size);
+                    size=SearchPath(NULL,filename,NULL,size,realname,NULL);
+                }
+                if (size==0)
+                {
+                    fprintf(stderr,"%s: File not found \"%s\" (%ld)\n",
+                            getAppName(),filename,GetLastError());
+                    exit(1);
+                }
+                reg_file = fopen(realname, "r");
+                if (reg_file==NULL)
+                {
                     perror("");
                     fprintf(stderr,"%s: Can't open file \"%s\"\n", getAppName(), filename);
                     exit(1);
                 }
+                processRegLines(reg_file, doSetValue);
+                if (realname)
+                {
+                    HeapFree(GetProcessHeap(),0,realname);
+                    fclose(reg_file);
+                }
                 get_file_name(&s, filename);
             }
             break;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux