Recent

Author Topic: [Solved] Problems with FileExists on Win7 x64  (Read 22528 times)

u2o

  • Jr. Member
  • **
  • Posts: 72
  • No message
Re: Problems with FileExists
« Reply #15 on: April 06, 2013, 08:40:37 pm »
In the meantime, if the purpose is to find out if there is 32 or 64 bit flash plugin, you can check that from Windows Registry. I seemed to find it at
HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayerActiveX\
PlayerPath = C:\Windows\system32\Macromed\Flash\Flash32_11_6_602_180.ocx

From that information you should be able to extract 32/64. Also it will work even if the windows user actually doesn't have 'C:\Windows\' at all, but like 'C:\MyCustomWinDirName\', as it is changeable on windows installation. Some have 'C:\WinNT\' etc.

Hi User137

See, the test are with real paths, I'm workin on an application launcher, it chech files (to know if is installed some app like FlashPlayer), of course, first get the system paths like %windir%

Code: [Select]
  if Is64Bits = True then begin
    CommonProgramFiles := GetWindowsSpecialDirUTF8(CSIDL_PROGRAM_FILES_COMMON);
    CommonProgramFilesx64 := GetEnvironmentVariableUTF8('CommonProgramW6432') + '\';

    ProgramFiles := GetWindowsSpecialDirUTF8(CSIDL_PROGRAM_FILESX86);
    ProgramFilesx64 := GetEnvironmentVariableUTF8('ProgramW6432') + '\';

    SystemDir := GetWindowsSpecialDirUTF8(CSIDL_SYSTEMX86);                      // WinX64 -> CSIDL_SYSTEMX86=C:\Windows\SysWOW64
    SystemDirx64 := GetWindowsSpecialDirUTF8(CSIDL_SYSTEM);                      // WinX64 -> CSIDL_SYSTEM=C:\Windows\System32
  end;


But that's not the point, because flash is always installed in the same sub location.
    %Windir%\System32\Macromed\Flash\*
    or
     %Windir%\SysWOW64\Macromed\Flash\*

If you get the path by Registry, when check if exist the files, same result...  :o

Here we see that FileExist, has a flaw in Windows 64bit? or with the virtualization of Windows 7 64bit?

But the path is real, not virtualized...

---- various edits ----
« Last Edit: April 06, 2013, 08:44:53 pm by u2o »

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Problems with FileExists
« Reply #16 on: April 07, 2013, 12:20:40 am »
The point is that a 32-bit program will never see the 64bit flash files in system32.
Only a 64-bit app will see them.

So you see them in console or explorer (they are 64-bit on Win7-64), but not in you own fpc program, unless compiled with 64-bit fpc.

So, windows is playing tricks with you.
It's not fpc, this (for fileExistst) just simply calls the Windows API GetFileAttributes.

So, for a 32-bit program to query wether a 64-bit app/driver is installed, you'll probably need to do it in another way.

Bart

Bart

u2o

  • Jr. Member
  • **
  • Posts: 72
  • No message
Re: Problems with FileExists
« Reply #17 on: April 07, 2013, 12:43:53 am »
Sorry Bart, but you are wrong... Please review previous messages...

........

but this works
Code: [Select]
FileExists('C:\Windows\System32\Macromed\Flash\FlashInstall.log'); //--> True

u2o

  • Jr. Member
  • **
  • Posts: 72
  • No message
Re: Problems with FileExists
« Reply #18 on: April 07, 2013, 12:55:19 am »
Try this

Code: [Select]
FileExists('C:\Windows\System32\catroot2\dberr.txt') // --> True

This file only exist on
    C:\Windows\System32\catroot2\
and not in
    C:\Windows\SysWOW64\catroot2\

---- EDIT ----

ohhhhhh! :-[ You are right!!!! 

Code: [Select]
FileExists('C:\Windows\System32\SysFxUI.dll') //--> False
FileExists('C:\Windows\System32\sysntfy.dll')  //--> False
« Last Edit: April 07, 2013, 12:59:25 am by u2o »

u2o

  • Jr. Member
  • **
  • Posts: 72
  • No message
Re: Problems with FileExists
« Reply #19 on: April 07, 2013, 01:12:33 am »
Some folders are not redirected: File System Redirector

Solution Found on AutoItScript Forum
Code: [Select]
FileExists('C:\Windows\Sysnative\Macromed\Flash\FlashUtil64_11_6_602_180_ActiveX.exe'); //--> True


Really sorry for being so stubborn...  :-[

Thanks to all! :)
« Last Edit: April 07, 2013, 01:18:11 am by u2o »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: [Solved] Problems with FileExists on Win7 x64
« Reply #20 on: April 07, 2013, 03:48:32 am »
The joys of Microsoft... :(
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

ahiggins

  • Jr. Member
  • **
  • Posts: 92
Re: [Solved] Problems with FileExists on Win7 x64
« Reply #21 on: July 14, 2014, 06:27:45 pm »
Just spent 3 hours trying to get my application to exec c:\windows\system32\manage-bde with no joy what so ever. Was just about to post a question and code sample when i read this post. 
complied my code as 64bit, Woohoo! goes to show just what a great resource this forum is. Bart you're a legend! many thanks.

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: [Solved] Problems with FileExists on Win7 x64
« Reply #22 on: July 14, 2014, 07:10:01 pm »
Thats...  so unintuitive...

Why did Microsoft implement it this way?   So sure, 32bit apps can't use 64bit dlls and verse vica, but to hide the 64bit files from 32bit apps...  Thats...  wrong...
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

 

TinyPortal © 2005-2018