Página 1 de 1

Informar OS e Arquitetura 32 ou 64 bits

Enviado: 30 Set 2021 09:55
por Jairo Maia
Olá Pessoal,

Como vocês fazem para dar essas informações diretamente pelo sistema de vocês? Da forma que uso funciona, mas gostaria de saber:

Código: Selecionar todos

Function Main()
 Local cArchiBit, cOsInfo
 
 If MyRun( "wmic os get osarchitecture > osarchitecture.txt", .T. )
  cArqBit := Hb_MemoRead( "osarchitecture.txt" )
  cArqBit := Upper( StrTran( cArqBit, Chr( 0 ) ) )
  cArqBit := If( "32-BIT" $ Upper( cArqBit ), " - 32-Bit", " - 64-Bit" )
 Else
  cArqBit := ""
 EndIf

 cOsInfo := "Seu Sistema Operacional:;;"
 cOsInfo += OS() + cArchiBit
 
 Hb_Alert( cOsInfo )
 
Return Nil

Function MyRun( cComando, lWait )         // executa programa externo
 Local oShell, lRet
 lWait := If( Empty( lWait ), .F., .T. )  // Se .T. aguarda o programa fechar, se .F. não aguarda...
 oShell := CreateObject( "WScript.Shell" )
 lRet := oShell:Run( "%comspec% /c " + cComando, 0, lWait )
 oShell := Nil
Return If( lRet = 0, .T., .F. )

Informar OS e Arquitetura 32 ou 64 bits

Enviado: 30 Set 2021 11:43
por JoséQuintas
Veja se tem mais coisa que interessa.

Código: Selecionar todos

#include "hbgtinfo.ch"
#include "hbmemory.ch"

FUNCTION pInfoJPA()

   LOCAL cText := "", cExeName, nThreads := 0

   cExeName := Upper( hb_FNameName( hb_ProgName() ) ) + ".EXE"
   cText += cExeName + ": " + AppVersaoExe() + hb_eol()
   cText += "Base de Dados: " + Transform( Str( AppVersaoSQL() * 100, 10 ), "@R 9999.99.99.99" ) + hb_eol()
   cText += "Hardware: " + DriveSerial() + hb_eol()
   cText += Version() + hb_eol()
   cText += HB_Compiler() + hb_eol()
   cText += "Available Memory: " + LTrim( Transform( Memory(0) / 1000, "999,999" ) ) + " MB" + hb_eol()
   cText += "Window Size (Row/Col): " + LTrim( Str( MaxRow() + 1 ) ) + " x " + LTrim( Str( MaxCol() + 1 ) ) + hb_eol()
   cText += "Window Size (Pixels): " + Ltrim( Str( hb_gtInfo( HB_GTI_SCREENWIDTH ) ) ) + " x " + ;
            Ltrim( Str( hb_gtInfo( HB_GTI_SCREENHEIGHT ) ) ) + hb_Eol()
   IF HB_GtInfo( HB_GTI_FONTNAME ) != NIL
      cText += "Font Name: " + HB_GTINFO( HB_GTI_FONTNAME ) + hb_eol()
      cText += "Font Size: " + LTrim(Str( HB_GTINFO( HB_GTI_FONTSIZE ) ) ) + " x " + LTrim( Str( HB_GTINFO( HB_GTI_FONTWIDTH ) ) ) + " x " + LTrim( Str( HB_GTINFO( HB_GTI_FONTWEIGHT ) ) ) + hb_eol()
   ENDIF
   cText += "Temp Path: " + AppTempPath() + hb_eol()
   cText += "Terminal Server Client: " + iif( win_OsIsTsClient(), "Yes", "No" ) + hb_eol()
   __vmCountThreads( @nThreads, 0 )
   cText += "Threads running " + Ltrim( Str( nThreads, 10 ) ) + hb_Eol()
   cText += "GT: " + hb_gtInfo( HB_GTI_VERSION ) + hb_Eol()
   cText += "OS: " + iif( hb_osIs64bit(), "64", "32" ) + " bits" + hb_Eol()
   MsgExclamation( cText )

   RETURN NIL
sobre.png

Informar OS e Arquitetura 32 ou 64 bits

Enviado: 30 Set 2021 13:10
por Jairo Maia
JoséQuintas escreveu:Veja se tem mais coisa que interessa.
Olá José, Obrigado por responder.

Eu já havia visto essa função sua aqui no fórum, mas veja que para o que eu preciso, é apenas informar qual Windows e qual Arquitetura. A rigor, como postei acima, para pegar a Arquitetura acho que estou meio na idade da pedra fazendo daquela forma. A ideia era saber se tem algo mais direto no Harbour.

Completando: hb_osIs64bit() é tudo que eu precisava, e não tinha reparado antes na sua postagem anterior. Valeu.

Informar OS e Arquitetura 32 ou 64 bits

Enviado: 30 Set 2021 17:41
por sygecom
Outra opção para pegar se o SISTEMA.EXE está em 32 ou 64

Código: Selecionar todos

FUNCTION WIN32_64BITS
   if ISWOW64()
      ShowMsg( "Windows 64 bits" )
   else
      ShowMsg( "Windows 32 bits" )
   endif
return nil

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

LPFN_ISWOW64PROCESS fnIsWow64Process;

HB_FUNC( ISWOW64 )
{
    BOOL bIsWow64 = FALSE;

    fnIsWow64Process = ( LPFN_ISWOW64PROCESS )
                       GetProcAddress( GetModuleHandle( TEXT( "kernel32" ) ), "IsWow64Process" );

    if( fnIsWow64Process )
        bIsWow64 = ! fnIsWow64Process( GetCurrentProcess(), &bIsWow64 );

    hb_retl( bIsWow64 );
}

#pragma ENDDUMP

Informar OS e Arquitetura 32 ou 64 bits

Enviado: 30 Set 2021 19:00
por JoséQuintas
Pode ser uma pergunta idiota, mas....

Aí está usando uma função do Kernel do Windows "IsWow64Process".
O Kernel 32 bits tem essa função?

Informar OS e Arquitetura 32 ou 64 bits

Enviado: 30 Set 2021 19:17
por sygecom
Sim, inclusive já to usando aqui.