 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Endy Guest
|
Posted: Tue Feb 20, 2007 8:24 pm Post subject: Including a unit only if Windows system is XP or Vista |
|
|
Hello,
We have a program that includes an unit in the project file. This unit
has an initialization part.
The program runs fine on Windows XP machines, but crashes on Windows
98.
Is there a way to say to the program not to include the unit if the
system is Windows 98? Can it be done with conditionals and can you
give an example?
Greetings
Endy |
|
| Back to top |
|
 |
Søren Bech Christensen Guest
|
Posted: Sat Feb 24, 2007 9:12 am Post subject: Re: Including a unit only if Windows system is XP or Vista |
|
|
Using units is done at compile-time, so it would make no sense to
platform specifik choices here.
Instead you must edit the initialization part of the used unit to
differentiate behavior depending on the executing platform.
Best
Søren |
|
| Back to top |
|
 |
Sv. Broholm Guest
|
Posted: Sun Feb 25, 2007 4:43 am Post subject: Re: Including a unit only if Windows system is XP or Vista |
|
|
On 24 Feb., 08:29, Søren Bech Christensen <sbc@A...@lodam.DOT.com>
wrote:
| Quote: | Using units is done at compile-time, so it would make no sense to
platform specifik choices here.
Instead you must edit the initialization part of the used unit to
differentiate behavior depending on the executing platform.
|
No, I disagree.
Include the unit at compiletime.
Test during initialization of the unit if it is executed on a WinNT-
family computer (yes, perform initialization) or a Win9x computer (no,
do not perform initialization).
The following code snip does the trick:
function WinNT : boolean;
Function GetRealDOSver : Word;
Var
Regs : Registers;
Begin
Regs.Ax := $3306;
MsDos( Regs );
GetRealDOSver := Regs.Bx;
End;
begin
If GetRealDOSver = $3205 Then
Begin
{ WinNT / 2000 / XP }
WinNT:=true;
End
Else
Begin
{ DOS / Win9x / WinME }
WinNT:=false;
End;
end;
begin
if WinNT then
PerformInitialization;
end.
Regards
Svend |
|
| Back to top |
|
 |
Endy Guest
|
Posted: Tue Feb 27, 2007 4:48 pm Post subject: Re: Including a unit only if Windows system is XP or Vista |
|
|
On 24 feb, 23:43, "Sv. Broholm" <sbroh...@gmail.com> wrote:
| Quote: | On 24 Feb., 08:29, Søren Bech Christensen <sbc@A...@lodam.DOT.com
wrote:
Using units is done at compile-time, so it would make no sense to
platform specifik choices here.
Instead you must edit the initialization part of the usedunitto
differentiate behavior depending on the executing platform.
No, I disagree.
Include theunitat compiletime.
Test during initialization of theunitifit is executed on a WinNT-
family computer (yes, perform initialization) or a Win9x computer (no,
do not perform initialization).
The following code snip does the trick:
function WinNT : boolean;
Function GetRealDOSver : Word;
Var
Regs : Registers;
Begin
Regs.Ax := $3306;
MsDos( Regs );
GetRealDOSver := Regs.Bx;
End;
begin
IfGetRealDOSver = $3205 Then
Begin
{ WinNT / 2000 /XP}
WinNT:=true;
End
Else
Begin
{ DOS / Win9x / WinME }
WinNT:=false;
End;
end;
begin
ifWinNT then
PerformInitialization;
end.
Regards
Svend
|
Hello Svend,
I tried your code but the problem is my Delphi version doesn't
recognize the "Registers" type. After googling I find out the "Dos"
unit contains this type. But when I add the unit to my uses clause, I
get the error "Dos.dcu" couldn't be found. We use Delphi 7.
Regards
Endy |
|
| Back to top |
|
 |
Sv. Broholm Guest
|
Posted: Wed Feb 28, 2007 5:29 am Post subject: Re: Including a unit only if Windows system is XP or Vista |
|
|
On 27 Feb., 11:48, "Endy" <andyimp...@pandora.be> wrote:
| Quote: | On 24 feb, 23:43, "Sv. Broholm" <sbroh...@gmail.com> wrote:
On 24 Feb., 08:29, Søren Bech Christensen <sbc@A...@lodam.DOT.com
wrote:
Using units is done at compile-time, so it would make no sense to
platform specifik choices here.
Instead you must edit the initialization part of the usedunitto
differentiate behavior depending on the executing platform.
No, I disagree.
Include theunitat compiletime.
Test during initialization of theunitifit is executed on a WinNT-
family computer (yes, perform initialization) or a Win9x computer (no,
do not perform initialization).
The following code snip does the trick:
function WinNT : boolean;
Function GetRealDOSver : Word;
Var
Regs : Registers;
Begin
Regs.Ax := $3306;
MsDos( Regs );
GetRealDOSver := Regs.Bx;
End;
begin
IfGetRealDOSver = $3205 Then
Begin
{ WinNT / 2000 /XP}
WinNT:=true;
End
Else
Begin
{ DOS / Win9x / WinME }
WinNT:=false;
End;
end;
begin
ifWinNT then
PerformInitialization;
end.
Regards
Svend
Hello Svend,
I tried your code but the problem is my Delphi version doesn't
recognize the "Registers" type. After googling I find out the "Dos"
unit contains this type. But when I add the unit to my uses clause, I
get the error "Dos.dcu" couldn't be found. We use Delphi 7.
Regards
Endy
|
My fault - this was correct for up to TP7/BP7.
For Delphi versions the code snip is as follows:
Program Init;
{$APPTYPE CONSOLE}
uses
Windows, SysUtils;
{-- From here and below goes into your unit --}
function IsWinNT: Boolean;
var
OS: TOsVersionInfo;
begin
OS.dwOSVersionInfoSize:=SizeOf(OS);
GetVersionEx(OS);
if OS.dwPlatformId = VER_PLATFORM_WIN32_NT then
Result := True else Result := False;
end;
begin
If IsWinNT Then
writeln('WinNT/2000/XP')
Else
writeln('DOS/Win9x/WinMe');
if isWinNT then
{ PerformInitializationOfUnit };
end.
Hope this helps.
Regards
Svend |
|
| Back to top |
|
 |
Endy Guest
|
Posted: Thu Mar 01, 2007 5:49 pm Post subject: Re: Including a unit only if Windows system is XP or Vista |
|
|
On 28 feb, 00:29, "Sv. Broholm" <sbroh...@gmail.com> wrote:
| Quote: | On 27 Feb., 11:48, "Endy" <andyimp...@pandora.be> wrote:
On 24 feb, 23:43, "Sv. Broholm" <sbroh...@gmail.com> wrote:
On 24 Feb., 08:29, Søren Bech Christensen <sbc@A...@lodam.DOT.com
wrote:
Using units is done at compile-time, so it would make no sense to
platform specifik choices here.
Instead you must edit the initialization part of the usedunitto
differentiate behavior depending on the executing platform.
No, I disagree.
Include theunitat compiletime.
Test during initialization of theunitifit is executed on a WinNT-
family computer (yes, perform initialization) or a Win9x computer (no,
do not perform initialization).
The following code snip does the trick:
function WinNT : boolean;
Function GetRealDOSver : Word;
Var
Regs : Registers;
Begin
Regs.Ax := $3306;
MsDos( Regs );
GetRealDOSver := Regs.Bx;
End;
begin
IfGetRealDOSver = $3205 Then
Begin
{ WinNT / 2000 /XP}
WinNT:=true;
End
Else
Begin
{ DOS / Win9x / WinME }
WinNT:=false;
End;
end;
begin
ifWinNT then
PerformInitialization;
end.
Regards
Svend
Hello Svend,
I tried your code but the problem is my Delphi version doesn't
recognize the "Registers" type. After googling I find out the "Dos"
unitcontains this type. But when I add theunitto my uses clause, I
get the error "Dos.dcu" couldn't be found. We use Delphi 7.
Regards
Endy
My fault - this was correct for up to TP7/BP7.
For Delphi versions the code snip is as follows:
Program Init;
{$APPTYPE CONSOLE}
uses
Windows, SysUtils;
{-- From here and below goes into yourunit--}
function IsWinNT: Boolean;
var
OS: TOsVersionInfo;
begin
OS.dwOSVersionInfoSize:=SizeOf(OS);
GetVersionEx(OS);
ifOS.dwPlatformId = VER_PLATFORM_WIN32_NT then
Result := True else Result := False;
end;
begin
IfIsWinNT Then
writeln('WinNT/2000/XP')
Else
writeln('DOS/Win9x/WinMe');
ifisWinNT then
{ PerformInitializationOfUnit };
end.
Hope this helps.
Regards
Svend- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -
|
Svend,
Thanks for your help... your solution works fine!
Regards
Endy |
|
| Back to top |
|
 |
Søren Bech Christensen Guest
|
Posted: Thu Mar 08, 2007 1:47 am Post subject: Re: Including a unit only if Windows system is XP or Vista |
|
|
Sv. Broholm wrote:
| Quote: | On 24 Feb., 08:29, Søren Bech Christensen <sbc@A...@lodam.DOT.com
wrote:
Using units is done at compile-time, so it would make no sense to
platform specifik choices here.
Instead you must edit the initialization part of the used unit to
differentiate behavior depending on the executing platform.
No, I disagree.
|
No you don't - your suggested solution uses exactly that approach. ;o)
-- |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|