Page 1 of 1
Help!
Posted: Sun Jun 29, 2003 3:31 pm
by Psychophanta
I have a question.
How can i do that a function is not compiled when my compiled program is executed under Windows NT 4.0?
The matter is that AnimateWindow_() MSWindows API function is not available in Windows NT (and maybe W95 neither), so i must use something like CompilerIf - CompilerEndIf part.
But CompilerIf command doesn't admit a variable, but only a constant:
Code: Select all
CompilerIf OSVersion()<>#PB_OS_Windows_NT_4
or similar doesn't work
And course, i can't do:
Code: Select all
if OSVersion=#PB_OS_Windows_NT_4
#OSV=0
else
#OSV=1
endif
Re: Help!
Posted: Sun Jun 29, 2003 3:36 pm
by tinman
Psychophanta wrote:How can i do that a function is not compiled when my compiled program is executed under Windows NT 4.0?
You cannot. Compile-time is when the executable is created, and has no knowledge of what happens when your program is executed.
You need to use a normal If...Else...EndIf structure to stop code being executed if the OS version is not suitable.
Re: Help!
Posted: Sun Jun 29, 2003 3:40 pm
by PB
Just do this for the time being (I know it isn't what you want, but at least
your app can do different things depending on the OS being used):
Code: Select all
If OSVersion()=#PB_OS_Windows_98
Debug "You are running Windows 98!"
Else
Debug "You are NOT running Windows 98."
EndIf
Posted: Sun Jun 29, 2003 6:02 pm
by Psychophanta
Oh, impossible too, i tried it calling to AW() instead:
Code: Select all
Procedure AW(wi,b,c)
If OSVersion=#PB_OS_Windows_NT_4
If c&#AW_HIDE:ShowWindow_(wi,#SW_HIDE):Else:ShowWindow_(wi,#SW_SHOW):EndIf
Else
AnimateWindow_(wi,b,c)
EndIf
EndProcedure
but when executable is runned under WinNT, this say that AnimateWindow() function is not available, and program is sharply terminated at the beginning.
It is because the function was compiled in the final code.
It seem not possible.

Posted: Sun Jun 29, 2003 6:21 pm
by freak
A placeholder for the Function will be compiled in the exe, the function
itself is inside a dll of the OS (in this case it is user32.dll)
You can call the function directly in the dll, so this placeholder won't be
compiled, and it should run.
Like this:
Code: Select all
Procedure AW(wi,b,c)
If OSVersion=#PB_OS_Windows_NT_4
If c&#AW_HIDE:ShowWindow_(wi,#SW_HIDE):Else:ShowWindow_(wi,#SW_SHOW):EndIf
Else
If OpenLibrary(0, "user32.dll") And IsFunction(0, "AnimateWindow")
CallFunction(0, "AnimateWindow", wi, b, c)
CloseLibrary(0)
Else ; In case something went wrong...
If c&#AW_HIDE:ShowWindow_(wi,#SW_HIDE):Else:ShowWindow_(wi,#SW_SHOW):EndIf
EndIf
EndIf
EndProcedure
Timo
Posted: Sun Jun 29, 2003 6:37 pm
by Psychophanta
So, i change the question:
It is possible to detect if a certain function is available in any lib in the system before call it?
Posted: Sun Jun 29, 2003 7:24 pm
by freak
That's what the IsFunction() in my example allready does.
Timo
Posted: Sun Jun 29, 2003 7:26 pm
by Psychophanta
Thank you, thank you, Timo. Great!
Moreover, you have answered my question.
I don't know how i didn't think about OpenLibrary(), because i have used a lot before. Brrrr
Now i got the good solution.
