You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
In what context? The #IF metastatement is a compile-time directive, so if your code worked it would be like saying "if this program is being compiled on Windows version 4 or later machine, include this code...".
But most programs are more interested in the Windows version at runtime, not compile time. If that is the case, you would need to use the GetVersion API function to determine what version of Windows is being used.
I have also seen that notation used to mean "if the Windows version is greater than or equal to 4, the operating system will return these values. Otherwise, it will return these other values."
Actually, now that I think about it, it may not matter what context you're talking about. Windows 95, 98, NT, and 2000 all have Windows version numbers that are greater than or equal to 4, so the only time you'd see <4 would be with Windows 3.x. And since the PB/CC and PB/DLL compilers require Windows 95 or better, your programs should never encounter <4.
Originally posted by Eric Pearson: In what context? The #IF metastatement is a compile-time directive, so if your code worked it would be like saying "if this program is being compiled on Windows version 4 or later machine, include this code...".
But most programs are more interested in the Windows version at runtime, not compile time. If that is the case, you would need to use the GetVersion API function to determine what version of Windows is being used.
I have also seen that notation used to mean "if the Windows version is greater than or equal to 4, the operating system will return these values. Otherwise, it will return these other values."
Actually, now that I think about it, it may not matter what context you're talking about. Windows 95, 98, NT, and 2000 all have Windows version numbers that are greater than or equal to 4, so the only time you'd see <4 would be with Windows 3.x. And since the PB/CC and PB/DLL compilers require Windows 95 or better, your programs should never encounter <4.
-- Eric
You are right, the sample is not the best, but what if i want to create different versions of my software for different destination-os like NT3.51, NT4, NT5 or WIN95, WIN98, WIN??.
My intention is that the compile-time directives should be more flexible to handle things like "#if _WIN32_IE >= 0x0400", "#if _WIN32_WINNT=0x0400 and WINVER=0x0400" or "#if _WIN32_WINDOWS=0x0410 and WINVER=0x0400"
It seems to me, that it is not possible at the moment, but i think such things should be possible in future versions of PBDLL/CC.
If you can put this in a pre-compile directive of some kind:
Code:
Function GetWindowsVersion() Export As String
Local osinfo As OSVERSIONINFO
Local lResult As Long
osinfo.dwOsVersionInfoSize = SizeOf(osinfo)
lResult = GetVersionEx(osinfo)
If IsFalse lResult Then
Function = "Windows"
Exit Function
End If
If osinfo.dwPlatformId = %VER_PLATFORM_WIN32_NT Then
Select Case osinfo.dwMajorVersion'
Case 4
Function = "Windows NT"
Case 5
Function = "Windows 2000"
End Select
ElseIf osinfo.dwPlatformId = %VER_PLATFORM_WIN32_WINDOWS Then
'dwPlatformId
Select Case osinfo.dwMinorVersion
Case < 10
Function = "Windows 95"
Case 10
If osinfo.dwPlatformId = 1 Then
Function = "Windows 98 OSR1"
ElseIf osinfo.dwPlatformId = 2 Then
Function = "Windows 98 OSR2"
Else
Function = "Windows 98"
End If
Case > 12 ???
Function = "Windows Mil."
End Select
End If
End Function
Scott Turchin
MCSE, MCP+I http://www.tngbbs.com
---------------------- True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi
My personal experience is that it is a mistake to create different executable files for different versions of Windows. It can be a distribution and update nightmare, so I always create a single EXE or DLL that makes runtime adjustments for the various versions of Windows. But if you really want to create different versions...
The only obstacle is that the PowerBASIC #IF metastatement does not currently support things like <= and =>. But if you want to create a complex set of individual "=" tests you can obtain exactly the same results. You would need to enumerate all of the versions of Windows that exist, rather than using things like "greater than or equal to version 4".
If your primary goal is to suggest that #IF might be enhanced to support < and > then I'm sure that many people here would agree with you.
Originally posted by Eric Pearson: If your primary goal is to suggest that #IF might be enhanced to support < and > then I'm sure that many people here would agree with you.
As i wrote above, that´s exactly the point!
Thank you and thanks Scott for your sample-code. This is how my program works at the moment.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment