there are some cases (they're rare, but exist), when you want to know the *bitness* of the OS,
your Application is running on (in most cases, when the Application is 32bit), to do some shell-
execution (in order to use correct parameters).
In this case it's Windows only, reason: WIN-API used. There must exist a similar API-call on LIN.
I've left the links to relevant resources in the code below:
Code: Select all
' AppBitnessOnWIN64.bas -- 2017-04-05, by MrSwiss
' MSDN -- C++ || dll = kernel32 || reference: https://blogs.msdn.microsoft.com/oldnewthing/20050201-00/?p=36553
/' https://msdn.microsoft.com/en-us/library/windows/desktop/ms684139(v=vs.85).aspx -- code below
HANDLE WINAPI GetCurrentProcess(void);
BOOL WINAPI IsWow64Process(
_In_ HANDLE hProcess,
_Out_ PBOOL Wow64Process
);
'/
' don't use it on WINNT32 OS, it's useless there, but try both FBC version's (32/64)
#Include Once "windows.bi"
Dim As Boolean self ' we're checking THIS process
Dim As Any Ptr p_s = @self ' we need a pointer to 'result'
IsWow64Process(GetCurrentProcess(), p_s) ' both are declared in "windows.bi"
' the outcome depends on the FBC (bitness) used (32 = TRUE / 64 = FALSE)
Print "Is this a WoW64 Application? (32bit App. on WIN64 OS?) = " + UCase(Str(self))
Print : Print
Print "any action QUIT's! ";
Sleep
Code: Select all
'#Define debug ' uncomment as needed
#Include Once "windows.bi"
Dim As Boolean self ' we're checking THIS process
Dim As Any Ptr p_s = @self ' we need a pointer to 'result'
IsWow64Process(GetCurrentProcess(), p_s) ' both are declared in "windows.bi"
Sub Message(ByVal msg As String, ByVal timeout As Long, ByVal WoW As Boolean)
#Ifdef __FB_64BIT__ ' 64bit OS & Application (Compiler)
Shell ("%SystemRoot%\System32\msg * /time:" + Str(timeout) + " " + msg)
#Else ' 32bit Compiler (check OS's bitness)
If WoW = TRUE Then ' WINNT64! - Application is 32bit
Shell ("%SystemRoot%\Sysnative\msg * /time:" + Str(timeout) + " " + msg)
Else ' WINNT32! - Application is 32bit
Shell ("%SystemRoot%\System32\msg * /time:" + Str(timeout) + " " + msg)
EndIf
#EndIf ' __FB_64BIT__
End Sub
#Ifdef debug
Message("LATEST NEWS IN 3 MINUTES !!! " + UCase(Str(self)), 5, self)
#Else
Message("LATEST NEWS IN 3 MINUTES !!! ", 5, self)
#EndIf
' ----- EOF -----