Page 2 of 2
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 2:47 pm
by PB
> What's your case scenario for your project?
I need to launch system apps for the user. Mobility Center was one,
but then I discovered the path used to run it with RunProgram wasn't
working, even though I knew the file existed, but FileSize said it didn't.
Code: Select all
; This FAILS on a 32-bit app running on a 64-bit PC.
RunProgram("C:\Windows\System32\mblctr.exe")
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 3:01 pm
by Thunder93
Different ways.. but depends on your needs.
Here's one example of many.
Code: Select all
Global Is64OS.l, EnvirSys32.s = GetEnvironmentVariable("SystemRoot")
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
Is64OS = Bool(FileSize(EnvirSys32+"\SysWOW64\"))
CompilerEndIf
If Is64OS : EnvirSys32 + "\SysNative\"
Else : EnvirSys32 + "\System32\"
EndIf
Debug FileSize(EnvirSys32+"mblctr.exe")
Debug EnvirSys32
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 3:16 pm
by PB
This...
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
...is not a solution, because it's NOT runtime. It sets the processor
type ONCE for the exe it creates. So if I compile my exe on a 64-bit
PC and then run it on a 32-bit, then Is64OS will be true on the 32-bit.
That's why we need a runtime command for PureBasic that returns the
processor type. It's been requested before but never added.

Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 3:19 pm
by Thunder93
You can run 64App on 32Bit OS?

Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 3:20 pm
by ts-soft
PB wrote:This...
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
checks only, you are compiling in 32-Bit. This have nothing to do with
the OS! You can remove this, if you compile your source always in 32-Bit.
You can't change the pb compiler at runtime, i hope

Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 3:32 pm
by PB
What I mean is this:
Code: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
MessageRequester("Result","32")
CompilerElse
MessageRequester("Result","64")
CompilerEndIf
If I compile an exe with this on a 32-bit PC, but then run the
exe on a 64-bit PC, the result will show "32", which is wrong.
No code in the 64-bit block will get executed because the exe
was built on a 32-bit PC due to CompilerIf locking the code.
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 3:41 pm
by Thunder93
There is a misunderstanding here or something...
If you make 32bit App, this will always check regardless if you on x86 or x64 OS .. to see if you have that \SysWOW64\ directory.
Re: FileSize says file does not exist
Posted: Wed Mar 05, 2014 3:43 pm
by ts-soft
PB wrote:What I mean is this:
Code: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
MessageRequester("Result","32")
This mean, you are using the 32-Bit Version of purebasic, nothing more.
Re: FileSize says file does not exist
Posted: Mon Mar 10, 2014 11:14 am
by Fred
We use regular Windows API to check the file size, so I bet it's an OS quirck and we won't fix that as it will probably brings other issues.
Re: FileSize says file does not exist
Posted: Mon Mar 10, 2014 11:18 am
by PB
> This mean, you are using the 32-Bit Version of purebasic, nothing more
Yes, which means Thunder93's code example is totally pointless.
Re: FileSize says file does not exist
Posted: Mon Mar 10, 2014 12:48 pm
by Thunder93
Its only pointless if one doesn't follow.
If you creating 64bit App, nothing needs to change. You should be calling the 64bit system versions on Windows x64.
If you creating a 32bit App, then you must also check to see if your 32bit App is running on a 64bit Windows.
With my existing code, and if I compile 32bit App. The following line will run the respectful version of the file. If I'm on the 32bit OS, works. If I'm on the 64bit OS, it works.
Code: Select all
RunProgram(EnvirSys32+"mblctr.exe")