ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

it's possible know when the some file is exactly present in the directory immediatlely its creation? GetFileInfo handle's and size's not enough. I need'nt use sistem(...).

if((command = OpenFile ("comandi.bat", VAL_WRITE_ONLY, VAL_OPEN_AS_IS, VAL_ASCII))==-1)
            {
                valido=ERR_OPEN_FILE;
                printf("Open comandi.bat failed!\n");
            }
            else
            {
                WriteFile (command,"@ipconfig /all > mac.txt & vol > vol.txt",41);
                CloseFile (command);
             
                handle=0; tempo=0; size=0;

                while(!handle && tempo<60)
                {
                    handle = GetFileInfo("comandi.bat",&size);
                    if(!size)
                        handle=0;
                    GetSystemTime (&ore, &minuti, &secondi);
                    if(secondi!=timeWait)
                    {
                        tempo++;
                        timeWait = secondi;
                    }
                }
                if(tempo==60)

                    valido=ERR_FILE_INFO;
                else
                {
                    size=0;
                    tempo=0;
                    if(LaunchExecutableEx ("comandi.bat", LE_HIDE, &handle))
                    {   
                        RetireExecutableHandle (handle);
                        valido=ERR_SYSTEM;
                    }
                    RetireExecutableHandle (handle);

 ..............................

 

GetFileInfo ne me garantie pas la présence physique du fichier "comandi.bat" parceque LaunchExecutableEx(...) ne trouve pas toujours ce fichier lorsqu'il est sollicité.

 

0 Kudos
Message 1 of 1
(3,054 Views)