www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/07/13:50:26

Sender: root AT delorie DOT com
Message-ID: <375C0879.A0720BD2@inti.gov.ar>
Date: Mon, 07 Jun 1999 14:59:21 -0300
From: salvador <salvador AT inti DOT gov DOT ar>
Organization: INTI
X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.0.36 i686)
X-Accept-Language: es-AR, en, es
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Open file created by child: problems under W95 (most machines)
Reply-To: djgpp AT delorie DOT com

Hi All:

  I have a problem in my installer, I'm calling regedit to get
information about the Windows installation and use it in my installer.
For that I call regedit using system. It works and regedit generates a
file with the information I need. But the problem comes whe I try to
read the information from this file. Looks like even when the file
exists I can't open it for a while (more than 1 second!), the most crazy
detail is that it happends in most machines I tried, but not all. I
don't have any problem at home using a K6-2 300MHz, but I have problems
at work using a Pentium II 333 MHz and the delay is over 1 second (I
tried waiting 1 s before opening the file and fails anyways) so isn't
the speed, is something with the Windows kernel.

  Here is a program to test it, in the machine I use at home it will
succed in 1 try, but here at work it needs around 5000 (or even more)
tries before the file is opened.
  As you can see the file exists (access says I can read it) and the
error is EACCES.
  Does anybody know why and if that's the right way to workaround this
beautiful gift from Redmond?

SET

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>

const char *name="temporal.txt";

int main(int argc, char *argv[])
{
 char buffer[PATH_MAX];

 printf("Calling regedit ...\n");
 sprintf(buffer,"regedit /E %s
HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion",name);

 system(buffer);

 FILE *f;
 int i=0;
 f=fopen(name,"rt");
 if (!f && access(name,R_OK)==0 && errno==EACCES)
   {
    do
     {
      f=fopen(name,"rt");
      i++;
     }
    while (!f);
   }

 if (f)
   {
    printf("OK! tried %d times\n",i);
    fclose(f);
   }
 else
    printf("Can you beleive it?\n");

 return 0;
}

--
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Visit my home page: http://welcome.to/SetSoft or
http://www.geocities.com/SiliconValley/Vista/6552/
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
                    set AT ieee DOT org set-soft AT bigfoot DOT com
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA Phone: +(5411) 4759 0013



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019