Re: [fpc-pascal] Function to know if WIN is 32 or 64

2011-03-16 Thread Marcos Douglas
On Wed, Mar 16, 2011 at 12:56 AM, Robert Wolfe wolfe.robwo...@gmail.com wrote:
 On 3/15/2011 10:25 AM, Marcos Douglas wrote:

 On Tue, Mar 15, 2011 at 11:13 AM, Henry Vermaakhenry.verm...@gmail.com
  wrote:

 On 15 March 2011 14:05, Marcos Douglasm...@delfire.net  wrote:

 Is there some function to know if the Windows is 32 or 64?

 You can use the GetNativeSystemInfo function.  Check
 TSystemInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64 to
 see if it's 64 bit.

 What unit?


 I've used this function in Delphi (7) and didn't work:
 function is64bitOS: boolean;
   var
     SysInfo: TSystemInfo;
   begin
     GetSystemInfo(SysInfo);
     Result := (
          (Sysinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64)
       or (Sysinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64)
       );
 end;


 Marcos Douglas
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal


 Not sure this will work for you or not, but here is what I use:

 Program OSType ;

 Uses SysUtils;

 Begin ;

   WriteLn ;
   {$IFDEF WIN32}
       WriteLn ('This is a 32-bit version of Windows.') ;
   {$ENDIF$}
   {$IFDEF WIN64}
       WriteLn ('This is a 64-bit version of Windows.') ;
   {$ENDIF}

 End.

 The value returned, however, depends on whether the 32-bit compiler of the
 64-bit cross-compiler was used.

Interesting. But I think not works on my case. The compiler is 32-bits
but Windows can vary.

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Function to know if WIN is 32 or 64

2011-03-16 Thread Juha Manninen
Marcos Douglas kirjoitti keskiviikko 16 maaliskuu 2011 13:18:41:
 On Wed, Mar 16, 2011 at 12:56 AM, Robert Wolfe wolfe.robwo...@gmail.com 
wrote:
WriteLn ;
{$IFDEF WIN32}
WriteLn ('This is a 32-bit version of Windows.') ;
{$ENDIF$}
{$IFDEF WIN64}
WriteLn ('This is a 64-bit version of Windows.') ;
{$ENDIF}
  
  End.
  
  The value returned, however, depends on whether the 32-bit compiler of
  the 64-bit cross-compiler was used.
 
 Interesting. But I think not works on my case. The compiler is 32-bits
 but Windows can vary.

I was also thinking to suggest the compile time IFDEFs.
If the application is compiled for 32-bits then it can behave like a 32-bit 
application. No need to check anything at runtime.

For what do you need the run-time info?

Regards,
Juha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Function to know if WIN is 32 or 64

2011-03-16 Thread Marcos Douglas
On Wed, Mar 16, 2011 at 9:21 AM, Juha Manninen
juha.mannine...@gmail.com wrote:
 Marcos Douglas kirjoitti keskiviikko 16 maaliskuu 2011 13:18:41:
 On Wed, Mar 16, 2011 at 12:56 AM, Robert Wolfe wolfe.robwo...@gmail.com
 wrote:
    WriteLn ;
    {$IFDEF WIN32}
        WriteLn ('This is a 32-bit version of Windows.') ;
    {$ENDIF$}
    {$IFDEF WIN64}
        WriteLn ('This is a 64-bit version of Windows.') ;
    {$ENDIF}
 
  End.
 
  The value returned, however, depends on whether the 32-bit compiler of
  the 64-bit cross-compiler was used.

 Interesting. But I think not works on my case. The compiler is 32-bits
 but Windows can vary.

 I was also thinking to suggest the compile time IFDEFs.
 If the application is compiled for 32-bits then it can behave like a 32-bit
 application. No need to check anything at runtime.

 For what do you need the run-time info?

The problem already been resolved (see the begin of this thread).
The program was compiled in 32-bits but I have to know what kind of OS
is running because my program needs to install somethings.

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] macros

2011-03-16 Thread Marcos Douglas
Hi,
Some day I saw an example using macros on the code.
I want to put the compiler version in an about form... I remember
something like %fpcversion%... %date%...whatever.

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] macros

2011-03-16 Thread Roland Schäfer
Hi,

INCLUDEs like these will insert the appropriate strings into your code:

{$INCLUDE %DATE%}
{$INCLUDE %TIME%}
{$INCLUDE %FPCTARGETCPU%}
{$INCLUDE %FPCTARGETOS%}
{$INCLUDE %FPCVERSION%}

There are more... AFAIK it's documented in the Programmer's Manual.

Cheers
Roland

On 3/16/2011 2:18 PM, Marcos Douglas wrote:
 Hi,
 Some day I saw an example using macros on the code.
 I want to put the compiler version in an about form... I remember
 something like %fpcversion%... %date%...whatever.
 
 Marcos Douglas
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] macros

2011-03-16 Thread Marcos Douglas
2011/3/16 Roland Schäfer roland.schae...@fu-berlin.de:
 Hi,

 INCLUDEs like these will insert the appropriate strings into your code:

 {$INCLUDE %DATE%}
 {$INCLUDE %TIME%}
 {$INCLUDE %FPCTARGETCPU%}
 {$INCLUDE %FPCTARGETOS%}
 {$INCLUDE %FPCVERSION%}

 There are more... AFAIK it's documented in the Programmer's Manual.

That is it!
Thanks.

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Function to know if WIN is 32 or 64

2011-03-16 Thread DaWorm
On Wed, Mar 16, 2011 at 8:45 AM, Marcos Douglas m...@delfire.net wrote:
 The program was compiled in 32-bits but I have to know what kind of OS
 is running because my program needs to install somethings.

That's why I needed it too.  In my case, my code is always 32 bit, but
to install a smart card NULL driver, I needed to be able to adjust
both the 32 bit registry and the 64 bit registry.  Just adjusting the
32 bit registry wasn't enough.  I also had to make sure the code was
being ran as an administrator.

Jeff.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Function to know if WIN is 32 or 64

2011-03-16 Thread Marcos Douglas
On Wed, Mar 16, 2011 at 12:19 PM, DaWorm daw...@gmail.com wrote:
 On Wed, Mar 16, 2011 at 8:45 AM, Marcos Douglas m...@delfire.net wrote:
 The program was compiled in 32-bits but I have to know what kind of OS
 is running because my program needs to install somethings.

 That's why I needed it too.  In my case, my code is always 32 bit, but
 to install a smart card NULL driver, I needed to be able to adjust
 both the 32 bit registry and the 64 bit registry.  Just adjusting the
 32 bit registry wasn't enough.

Exactly.

 I also had to make sure the code was
 being ran as an administrator.

That's nice. Can you share the function?


Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Function to know if WIN is 32 or 64

2011-03-16 Thread DaWorm
On Wed, Mar 16, 2011 at 11:25 AM, Marcos Douglas m...@delfire.net wrote:
 I also had to make sure the code was
 being ran as an administrator.

 That's nice. Can you share the function?

Again, don't remember where I found this, Google or MSDN probably.
Only tested in Delphi.

function IsAdmin: Boolean;
{ -
  Returns a boolean indicating whether or not user has admin
  privileges. (Call only when running under NT.)

  - }
var
  hAccessToken   : tHandle;
  ptgGroups  : pTokenGroups;
  dwInfoBufferSize   : DWORD;
  psidAdministrators : PSID;
  int: integer;// counter
  blnResult  : boolean;// return flag

const
 SECURITY_NT_AUTHORITY: SID_IDENTIFIER_AUTHORITY = (Value:
(0,0,0,0,0,5)); // ntifs
 SECURITY_BUILTIN_DOMAIN_RID: DWORD = $0020;
 DOMAIN_ALIAS_RID_ADMINS: DWORD = $0220;
 DOMAIN_ALIAS_RID_USERS : DWORD = $0221;
 DOMAIN_ALIAS_RID_GUESTS: DWORD = $0222;
 DOMAIN_ALIAS_RID_POWER_: DWORD = $0223;

begin
 Result := False;
 ptgGroups := nil;
 blnResult := OpenThreadToken( GetCurrentThread, TOKEN_QUERY, True,
   hAccessToken );
 if ( not blnResult ) then
  begin
   if GetLastError = ERROR_NO_TOKEN then
blnResult := OpenProcessToken( GetCurrentProcess, TOKEN_QUERY,
   hAccessToken );
  end;
 if ( blnResult ) then
  try
   GetMem(ptgGroups, 1024);
   blnResult := GetTokenInformation( hAccessToken, TokenGroups, ptgGroups, 1024,
 dwInfoBufferSize );
   CloseHandle( hAccessToken );
   if ( blnResult ) then
begin
 AllocateAndInitializeSid( SECURITY_NT_AUTHORITY, 2,
   SECURITY_BUILTIN_DOMAIN_RID,
   DOMAIN_ALIAS_RID_ADMINS,
   0, 0, 0, 0, 0, 0,
   psidAdministrators );
 {$R-}
 for int := 0 to ptgGroups.GroupCount - 1 do
  if EqualSid( psidAdministrators, ptgGroups.Groups[ int ].Sid ) then
   begin
Result := True;
Break;
   end;
 {$R+}
 FreeSid( psidAdministrators );
end;
  finally
   FreeMem( ptgGroups );
  end;
end;
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Function to know if WIN is 32 or 64

2011-03-16 Thread Marcos Douglas
On Wed, Mar 16, 2011 at 2:23 PM, DaWorm daw...@gmail.com wrote:
 On Wed, Mar 16, 2011 at 11:25 AM, Marcos Douglas m...@delfire.net wrote:
 I also had to make sure the code was
 being ran as an administrator.

 That's nice. Can you share the function?

 Again, don't remember where I found this, Google or MSDN probably.
 Only tested in Delphi.

 function IsAdmin: Boolean;
 [..]

Thanks, I will test.

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Function to know if WIN is 32 or 64

2011-03-16 Thread Robert Wolfe

On 3/16/2011 8:45 AM, Marcos Douglas wrote:

On Wed, Mar 16, 2011 at 9:21 AM, Juha Manninen
juha.mannine...@gmail.com  wrote:

Marcos Douglas kirjoitti keskiviikko 16 maaliskuu 2011 13:18:41:

On Wed, Mar 16, 2011 at 12:56 AM, Robert Wolfewolfe.robwo...@gmail.com

wrote:

   WriteLn ;
   {$IFDEF WIN32}
   WriteLn ('This is a 32-bit version of Windows.') ;
   {$ENDIF$}
   {$IFDEF WIN64}
   WriteLn ('This is a 64-bit version of Windows.') ;
   {$ENDIF}

End.

The value returned, however, depends on whether the 32-bit compiler of
the 64-bit cross-compiler was used.

Interesting. But I think not works on my case. The compiler is 32-bits
but Windows can vary.

I was also thinking to suggest the compile time IFDEFs.
If the application is compiled for 32-bits then it can behave like a 32-bit
application. No need to check anything at runtime.

For what do you need the run-time info?

The problem already been resolved (see the begin of this thread).
The program was compiled in 32-bits but I have to know what kind of OS
is running because my program needs to install somethings.



So you are writing your own application installer then?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Function to know if WIN is 32 or 64

2011-03-16 Thread Marcos Douglas
On Wed, Mar 16, 2011 at 3:21 PM, Robert Wolfe wolfe.robwo...@gmail.com wrote:
 On 3/16/2011 8:45 AM, Marcos Douglas wrote:

 [...]
 The problem already been resolved (see the begin of this thread).
 The program was compiled in 32-bits but I have to know what kind of OS
 is running because my program needs to install somethings.


 So you are writing your own application installer then?

I wrote (done!) an installer to an old application that no have installer.
Was my first (real or in production) application using FPC and Lazarus.

This old application uses Oracle, BDE and don't have installer... and,
for my client, this is a big problem...
I will talk about that in another thread.

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Thank you FPC team, Lazarus team and all the community

2011-03-16 Thread Marcos Douglas
Hi,

I wrote my first (real or in production) job using FPC and
Lazarus, after more than 10 year working with Delphi.
An installer to an old application that no have installer.  =)

This old application uses Oracle, BDE and don't have installer... and,
for my client, this is a big problem.

The program call the Oracle Installer; sets some Oracle's files;
installs the BDE (this is little different if the WIN is 32-bits or
64-bits); installs the application (using the Windows Register) and
creates a Shortcut on Desktop.

The installer is simple. Some options and one button. But it do things
that is a headache for my client so, it was a success!

As I said, this is my first job with FPC and I'm impressed! The
transition from Delphi 7 to Lazarus was very simple.

Thank you all the community. Thank you FPC team and Lazarus team, you
did a great job.


Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Free Pascal 2.4.4 RC1 available

2011-03-16 Thread Marco van de Voort
Hello,

We have placed the first release-candidate of the Free Pascal Compiler
version 2.4.4 on our ftp-servers.

You can help improve the upcoming 2.4.4 release by downloading and
testing this release. If you want you can report what you have done here:
http://wiki.freepascal.org/Testers_2.4.4

Changes that may break backwards compatibility are documented at:
http://wiki.freepascal.org/User_Changes_2.4.4

Downloads are available at:

the main FTP server at

ftp://ftp.freepascal.org/pub/fpc/beta/2.4.4-rc1/

and

ftp://freepascal.stack.nl/pub/fpc/beta/2.4.4-rc1/

Note:

Some platforms are still being uploaded, among them Mac OS X, Linux/i386 and
Linux/x86_64.

Enjoy!

The Free Pascal Compiler Team

Free Pascal Compiler

Version 2.4.4rc1

**
  What's New in 2.4.4rc1
**

Free Pascal 2.4.4 contains most library fixes from early June 2010 till March
2011. There are also some compiler fixes, most relating to 64-bit.

Please also see http://wiki.freepascal.org/User_Changes_2.4.4 for a list
of changes which may affect the behaviour of previously working code, and
how to cope with these changes.

Some highlights are:

Packages:
  * Many improvements to the XML units
  * Many improvements to the database units. 
* Specially sqlite got quite some fixes.
  * Many improvements to the chm units. 
* Including a commandline CHM compiler 
  * Many improvements to fppkg and fpmake for another round of testing.

Platforms:
  * Fixes for multi-threading support in OS/2 RTL.

See http://bugs.freepascal.org/changelog_page.php for the list of reported
bugs which have been fixed in this release.


**
  What's New in 2.4.2
**

Free Pascal 2.4.2 contains many fixes and a few new features. Most bugfixes
in the RTL and packages before June 2010 have been merged.

Please also see http://wiki.freepascal.org/User_Changes_2.4.2 for a list
of changes which may affect the behaviour of previously working code, and
how to cope with these changes.

Some highlights are:

Compiler:
  * Support D2006+ FOR..IN, with some FPC specific enhancements. Refer to
 http://wiki.freepascal.org/for-in_loop for more information
  * Support for sealed and abstract classes.

Packages:
  * The existing Mac OS X Universal Interfaces units have been synchronised
with the Mac OS X 10.6 SDK. Several new units have also been added, and
where indicated in the Mac OS X 10.6 SDK they have also been enabled for
iPhoneOS/iOS.
  * Many improvements to the XML units
  * Many improvements to the database units
  * Many improvemnets to the chm units

Platforms:
  * Long term bug in OS/2 implementation of unit Video finally fixed which
among others allows inclusion of the text-mode IDE (without debugger)
for this platform as part of the distribution again.

See http://bugs.freepascal.org/changelog_page.php for the list of reported
bugs which have been fixed in this release.


**
  What's New in 2.4.0
**

Free Pascal 2.4.0 contains many fixes and new features. While we did not
manage to incorporate all planned additions, we believe this release offers a
nice collection of new functionality and bug fixes.


Please also see http://wiki.freepascal.org/User_Changes_2.4.0 for a list
of changes which may affect the behaviour of previously working code, and
how to cope with these changes.

Some highlights are:

Platforms:
  * New platform: Mac OS X/PowerPC64
  * New platform: Mac OS X/x86_64
  * New platform: Mac OS X/ARM (iPhone)

Compiler:
  * Support for Delphi-style resource handling
  * Whole-program optimization infrastructure, which initially supports
program devirtualization and unused virtual method removal
  * Much faster compilation of units containing many type-sections
  * The ability to suppress individual hints/warnings/notes
  * Several improvements to the DWARF debug information generation
  * Fixes to the generics support
  * Fixes to the interface delegation (implements) support
  * Improved cpu register allocation
  * Improved ARM/EABI support
  
RTL:
  * Linearly scaling multi-threaded memory manager
  * Support for (advisory) file locking on Unix-based platforms
when using the SysUtils file creation/opening routines
  * Support for ANSI ISO Extended Pascal ReadStr/WriteStr
  * A UnicodeString type that, while not yet equivalent to Delphi 2009's
UnicodeString type, offers reference counted UnicodeString support on
the 

Re: [fpc-pascal] Free Pascal 2.4.4 RC1 available

2011-03-16 Thread silvioprog
Mega-big-full-ultra-power thanks. :)

I published this announcement here in Brazil.

Thanks again.

-- 
Silvio Clécio
=
Blog - silvioprog.com.br
Twitter - twitter.com/silvioprog
LazSolutions - code.google.com/p/lazsolutions
Lazarus-BR - http://groups.google.com.br/group/lazarus-br?hl=pt-BR
=

2011/3/16 Marco van de Voort mar...@stack.nl:
 Hello,

 We have placed the first release-candidate of the Free Pascal Compiler
 version 2.4.4 on our ftp-servers.

 You can help improve the upcoming 2.4.4 release by downloading and
 testing this release. If you want you can report what you have done here:
 http://wiki.freepascal.org/Testers_2.4.4

 Changes that may break backwards compatibility are documented at:
 http://wiki.freepascal.org/User_Changes_2.4.4

 Downloads are available at:

 the main FTP server at

 ftp://ftp.freepascal.org/pub/fpc/beta/2.4.4-rc1/

 and

 ftp://freepascal.stack.nl/pub/fpc/beta/2.4.4-rc1/

 Note:

 Some platforms are still being uploaded, among them Mac OS X, Linux/i386 and
 Linux/x86_64.

 Enjoy!

 The Free Pascal Compiler Team

                            Free Pascal Compiler

                                Version 2.4.4rc1

 **
                              What's New in 2.4.4rc1
 **

 Free Pascal 2.4.4 contains most library fixes from early June 2010 till March
 2011. There are also some compiler fixes, most relating to 64-bit.

 Please also see http://wiki.freepascal.org/User_Changes_2.4.4 for a list
 of changes which may affect the behaviour of previously working code, and
 how to cope with these changes.

 Some highlights are:

 Packages:
  * Many improvements to the XML units
  * Many improvements to the database units.
        * Specially sqlite got quite some fixes.
  * Many improvements to the chm units.
        * Including a commandline CHM compiler
  * Many improvements to fppkg and fpmake for another round of testing.

 Platforms:
  * Fixes for multi-threading support in OS/2 RTL.

 See http://bugs.freepascal.org/changelog_page.php for the list of reported
 bugs which have been fixed in this release.


 **
                              What's New in 2.4.2
 **

 Free Pascal 2.4.2 contains many fixes and a few new features. Most bugfixes
 in the RTL and packages before June 2010 have been merged.

 Please also see http://wiki.freepascal.org/User_Changes_2.4.2 for a list
 of changes which may affect the behaviour of previously working code, and
 how to cope with these changes.

 Some highlights are:

 Compiler:
  * Support D2006+ FOR..IN, with some FPC specific enhancements. Refer to
     http://wiki.freepascal.org/for-in_loop for more information
  * Support for sealed and abstract classes.

 Packages:
  * The existing Mac OS X Universal Interfaces units have been synchronised
    with the Mac OS X 10.6 SDK. Several new units have also been added, and
    where indicated in the Mac OS X 10.6 SDK they have also been enabled for
    iPhoneOS/iOS.
  * Many improvements to the XML units
  * Many improvements to the database units
  * Many improvemnets to the chm units

 Platforms:
  * Long term bug in OS/2 implementation of unit Video finally fixed which
    among others allows inclusion of the text-mode IDE (without debugger)
    for this platform as part of the distribution again.

 See http://bugs.freepascal.org/changelog_page.php for the list of reported
 bugs which have been fixed in this release.


 **
                              What's New in 2.4.0
 **

 Free Pascal 2.4.0 contains many fixes and new features. While we did not
 manage to incorporate all planned additions, we believe this release offers a
 nice collection of new functionality and bug fixes.


 Please also see http://wiki.freepascal.org/User_Changes_2.4.0 for a list
 of changes which may affect the behaviour of previously working code, and
 how to cope with these changes.

 Some highlights are:

 Platforms:
  * New platform: Mac OS X/PowerPC64
  * New platform: Mac OS X/x86_64
  * New platform: Mac OS X/ARM (iPhone)

 Compiler:
  * Support for Delphi-style resource handling
  * Whole-program optimization infrastructure, which initially supports
    program devirtualization and unused virtual method removal
  * Much faster compilation of units containing many type-sections
  * The ability to suppress individual hints/warnings/notes
  * Several improvements to the DWARF debug information generation
  * Fixes to the generics support
  * Fixes to the interface