Hola.
Necesito saber si puedo identificar si el sistema esta corriendo en PC o Notebook.
Como se puede hacer?
Gracias
José
Hola.
Necesito saber si puedo identificar si el sistema esta corriendo en PC o Notebook.
Como se puede hacer?
Gracias
José
C:\fwh\samples\pcinfo.prgGracias Joao, pero en mi version de fwh no tengo ese ejemplo.
Gracias igual.
#include "fivewin.ch"
#define NOGDIP
#define HKEY_LOCAL_MACHINE 2147483650 // 0x80000002
#ifndef HKEY_CURRENT_USER
#define HKEY_CURRENT_USER 2147483649 // 0x80000001
#endif
//----------------------------------------------------------------------------//
function Main()
local oInfo
? "start"
oInfo := TPCInfo():New()
oInfo:Show()
return nil
//----------------------------------------------------------------------------//
CLASS TPCInfo
DATA Brand AS CHARACTER INIT GetBrand()
DATA Model AS CHARACTER INIT GetBrand( .t. )
DATA cWinVersion AS CHARACTER INIT "Windows " + cWinVersion()
DATA OS AS CHARACTER
DATA OSVersion
DATA RAMGB AS NUMERIC INIT ROUND( ( Int( nExtMem() / ( 1024 * 1024 ) ) + 1 ) /1000, 0 )
DATA RAM_WMI AS NUMERIC INIT ComputerSystemMemory()
DATA RAM_2 AS NUMERIC INIT ComputerSystemMemory2()
DATA Processor AS CHARACTER INIT GetCPU()
DATA CPUSpeed AS NUMERIC INIT GetCPUspeed()
DATA GraphicCard AS CHARACTER INIT GetDisplayDevice()
DATA GraphicMemory AS CHARACTER INIT VideoControllerMemory()
DATA lBattery AS LOGICAL INIT CheckBattery()
DATA lCharger
DATA lTouchScreen INIT FW_IsTouchScreen()
DATA ScreenSize INIT Round( ScreenSize( .T. ), 1 )
DATA HDD
DATA aDisk INIT Array( 0 )
METHOD New() CONSTRUCTOR
METHOD Show()
METHOD ReadDiskInfo()
METHOD GetWMIOS()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New() CLASS TPCInfo
// ::HDD := GetDiskInfo()
::ReadDiskInfo()
::GetWMIOS()
return Self
//----------------------------------------------------------------------------//
METHOD Show() CLASS TPCInfo
local aInfo, n, cText, x
aInfo := { ;
{ "Brand", ::Brand }, ;
{ "Model", ::Model }, ;
{ "FWH-WinVersion", ::cWinVersion }, ;
{ "OS", ::OS }, ;
{ "OS Version", ::OSVersion }, ;
{ "RAM (GB)", cValToChar( ::RAMGB ) + " GB" }, ;
{ "RAM_WMI", Transform( ::RAM_WMI, "99.99999" ) + " GB" }, ;
{ "RAM_2", Transform( ::RAM_2, "99.99999" ) + " GB" }, ;
{ "Processor", ::Processor }, ;
{ "ProcessorSpeed", cValToStr( ::CPUSpeed ) }, ;
{ "GraphicCard", ::GraphicCard }, ;
{ "GraphicMemory", ::GraphicMemory }, ;
{ "HasBattery?", If( ::lBattery, "HAS BATTERY", "NO BATTERY" ) }, ;
{ "Has Charger?", iF( ::lBattery, "ENTER MANUALLY", "NOT APPLICABLE" ) }, ;
{ "TouchScreen", If( ::lTouchScreen, "YES" + TouchPoints(), "NO" ) }, ;
{ "ScreenSize (inches)", cValToChar( ::ScreenSize ) + " Inches" } }
for n := 1 to Len( ::aDisk )
cText := ::aDisk[ n, 2 ]
if !Empty( cText )
cText += " : "
endif
cText += ::aDisk[ n, 3 ]
if ! Empty( ::aDisk[ n, 4 ] )
cText += " (" + cValToChar( Round( ::aDisk[ n, 4 ] / 1000 / 1000 / 1000, 0 ) ) + " GB) "
endif
cText += ::aDisk[ n, 5 ]
AAdd( aInfo, { "Disk " + If( Len (::aDisk) > 1, Str( n, 1 ), "" ), cText } )
next
#ifdef NOGDIP
AEval( aInfo, { |a,i| aInfo[ i ] := FW_ArrayAsList( a, " : " ) } )
cText := FW_ArrayAsList( aInfo, CRLF )
MEMOWRIT( "pcinfo.txt", cText )
WinExec( "notepad.exe pcinfo.txt" )
#else
XBROWSER aInfo TITLE NETNAME() AUTOFIT ;
SETUP oBrw:bRClicked := { |r,c,f,o| BrowseToClipBoard( o ) }
#endif
return nil
//----------------------------------------------------------------------------//
METHOD ReadDiskInfo() CLASS TPCInfo
local cRet := "?"
local aRet := {}
local oWmi, oList, oDisk
oWmi := WMIService()
oList := oWmi:ExecQuery( "select * from Win32_DiskDrive" )
if oList:Count() > 0
for each oDisk in oList
if ValType( oDisk:Index ) == 'N'
AAdd( aRet, { oDisk:Index, IfNil( oDisk:MediaType, "" ), IfNil( oDisk:InterfaceType, "" ), ;
Val( IfNil( oDisk:Size, "" ) ), IfNil( oDisk:Caption, "" ) } )
endif
next
else
cRet := "NO DISK"
endif
ASort( aRet, nil, nil, { |x,y| x[ 1 ] < y[ 1 ] } )
::aDisk := aRet
return cRet
//----------------------------------------------------------------------------//
METHOD GetWMIOS() CLASS TPcInfo
local oWMI := WMIService()
local oList, oPC, u
local cRet := ""
oList := oWmi:ExecQuery( "select * from Win32_OperatingSystem" )
if oList:Count() > 0
for each oPC in oList
if oPC:Caption != nil
cRet := oPC:Caption
TRY
cRet += " " + oPC:OsArchitecture
CATCH
END
cRet := StrTran( cRet, "Microsoft ", "" )
TRY
u := oPC:BuildNumber
CATCH
END
if ! Empty( u )
cRet += " (Build : " + cValToChar( oPc:BuildNumber ) + ")"
endif
::OS := cRet
::OSVersion := opc:Version
EXIT
endif
next
endif
return cRet
//----------------------------------------------------------------------------//
function GetBrand( lModel )
local oReg, cVal
oReg := TReg32():New( HKEY_LOCAL_MACHINE,;
"SYSTEM\HardwareConfig\Current",;
.F. )
DEFAULT lModel := .f.
if lModel
cVal := oReg:Get( "SystemProductName", "" )
if Empty( cVal )
cVal := ComputerSystemProduct()[ 1 ]
endif
else
cVal := oReg:Get( "SystemManufacturer", "" )
if Empty( cVal )
cVal := ComputerSystemProduct()[ 2 ]
endif
endif
return cVal
//----------------------------------------------------------------------------//
function CheckBattery()
local oWMI := WMIService()
local oList
oList := oWmi:ExecQuery( "select * from Win32_Battery" )
return oList:Count() > 0
//----------------------------------------------------------------------------//
function VideoControllerMemory
local oWMI := WMIService()
local oList, oVC
local GB := 1024*1024*1024
local nRet := "0"
oList := oWmi:ExecQuery( "select * from Win32_VideoController" )
if oList:Count() > 0
for each oVC in oList
if oVC:AdapterRAM != nil
nRet := oVC:AdapterRAM/GB
if nRet < 0.9
nRet := cValToChar( nRet * 1024 ) + " MB"
else
nRet := Str( nRet, 2, 0 ) + " GB"
endif
endif
next
endif
return nRet
//----------------------------------------------------------------------------//
function ComputerSystemProduct()
local oWMI := WMIService()
local oList, oPC
local cName
local cVendor
oList := oWmi:ExecQuery( "select * from Win32_ComputerSystemProduct" )
if oList:Count() > 0
for each oPC in oList
TRY
cName := oPC:Name
CATCH
END
TRY
cVendor := oPC:Vendor
CATCH
END
if cName != nil .or. cVendor != nil
return { IfNil( cName, "NA" ), IfNil( cVendor, "NA" ) }
endif
next
endif
return { "NA", "NA" }
//----------------------------------------------------------------------------//
function ComputerSystemMemory()
local oWMI := WMIService()
local oList, oPC
local Memory := 0
oList := oWmi:ExecQuery( "select * from Win32_ComputerSystem" )
if oList:Count() > 0
for each oPC in oList
TRY
Memory := oPC:TotalPhysicalMemory
CATCH
END
Memory := Val( IfNil( Memory, "" ) )
Memory /= ( 1024 * 1024 * 1000 )
next
endif
return Memory
//----------------------------------------------------------------------------//
function ComputerSystemMemory2() // By AnserKK
local oWMI := WMIService()
local oList, oPC
local Memory := 0
Local nTotMemory:=0
oList := oWmi:ExecQuery( "Select * from CIM_PhysicalMemory" )
if oList:Count() > 0
for each oPC in oList
Memory := 0
TRY
Memory := oPC:Capacity
CATCH
END
Memory := Val( IfNil( Memory, "" ) )
Memory /= ( 1024 * 1024 * 1000 )
nTotMemory+=Memory
next
endif
return nTotMemory
//----------------------------------------------------------------------------//
function TouchPoints()
local cPoints := ""
local nPoints
nPoints := GetSysMetrics( 95 )
if nPoints > 0
cPoints := " (" + cValToChar( nPoints ) + " Touch Points)"
endif
return cPoints
//----------------------------------------------------------------------------//
function BrowseToClipBoard( oBrw )
local a := AClone( oBrw:aSelected )
oBrw:aSelected := ArraY( oBrw:nlen )
AEval( oBrw:aSelected, { |u,i| oBrw:aSelected[ i ] := i } )
oBrw:Copy()
oBrw:aSelected := a
MsgInfo( "Copied to Clip Board" )
return nil
//----------------------------------------------------------------------------//
function WMIService()
// It would be useful to keep this function in the library
static oWMI
local oLocator
if oWMI == nil
oLocator := CREATEOBJECT( "wbemScripting.SwbemLocator" )
oWMI := oLocator:ConnectServer()
endif
return oWMI
//------------------------------------------------------------------------------
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
HB_FUNC (GETDISPLAYDEVICE)
{
DISPLAY_DEVICE dd;
dd.cb = sizeof( dd );
EnumDisplayDevices( NULL, 0, &dd, 0 );
hb_retc( dd.DeviceString );
}
#pragma ENDDUMP
//----------------------------------------------------------------------------//Muchas gracias Antonio.
lo incluiré en la compilación y probaré.