Jump to content
Fivewin Brasil

HKEY_LOCAL_MACHINE no Windows 8 ou 8.1


leo@lhsistemas.com

Recommended Posts

Tente assim, eu coloco no fivewin.ch

#ifndef __XPP__
#define HKEY_CLASSES_ROOT 2147483648
#define HKEY_CURRENT_USER 2147483649
#define HKEY_LOCAL_MACHINE 2147483650
#define HKEY_USERS 2147483651
#define HKEY_PERFORMANCE_DATA 2147483652
#define HKEY_CURRENT_CONFIG 2147483653
#define HKEY_DYN_DATA 2147483654
#else
#define HKEY_CLASSES_ROOT 1
#define HKEY_CURRENT_USER 2
#define HKEY_LOCAL_MACHINE 3
#define HKEY_USERS 4
#define HKEY_PERFORMANCE_DATA 5
#define HKEY_CURRENT_CONFIG 6
#define HKEY_DYN_DATA 7
#endif
Link to comment
Share on other sites

Tente assim, eu coloco no fivewin.ch

#ifndef __XPP__
#define HKEY_CLASSES_ROOT 2147483648
#define HKEY_CURRENT_USER 2147483649
#define HKEY_LOCAL_MACHINE 2147483650
#define HKEY_USERS 2147483651
#define HKEY_PERFORMANCE_DATA 2147483652
#define HKEY_CURRENT_CONFIG 2147483653
#define HKEY_DYN_DATA 2147483654
#else
#define HKEY_CLASSES_ROOT 1
#define HKEY_CURRENT_USER 2
#define HKEY_LOCAL_MACHINE 3
#define HKEY_USERS 4
#define HKEY_PERFORMANCE_DATA 5
#define HKEY_CURRENT_CONFIG 6
#define HKEY_DYN_DATA 7
#endif

Quero ver é você pegar o UTC Aferra. kkkkkkkkkkkkkkkkkkkk

Link to comment
Share on other sites

Aferra, bom dia.

Segue exemplo abaixo:

**************************************************

Function main()

Msginfo(_timezone())

return(NIL)

**************************************************

Function _TimeZone()
Local cUTC := "",oReg,nValor

#ifndef __XPP__
#define HKEY_CLASSES_ROOT 2147483648
#define HKEY_CURRENT_USER 2147483649
#define HKEY_LOCAL_MACHINE 2147483650
#define HKEY_USERS 2147483651
#define HKEY_PERFORMANCE_DATA 2147483652
#define HKEY_CURRENT_CONFIG 2147483653
#define HKEY_DYN_DATA 2147483654
#else
#define HKEY_CLASSES_ROOT 1
#define HKEY_CURRENT_USER 2
#define HKEY_LOCAL_MACHINE 3
#define HKEY_USERS 4
#define HKEY_PERFORMANCE_DATA 5
#define HKEY_CURRENT_CONFIG 6
#define HKEY_DYN_DATA 7
#endif

#ifdef __XHARBOUR__
cUTC := Left(Alltrim(Str(TimeZone())),1)+StrZero(Val(SubStr(Alltrim(Str(TimeZone())),2)),2)+":00"
#endif

// SE HOUVE FALHA NA FUNCAO ACIMA, EXECUTA NA MAO A LEITURA DO REGISTRO //

If Val(Left(cUTC,3)) = 0

// WINDOWS 8/8.1 NAO CONSEGUI LER //

oReg := TReg32():New(HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\TimeZoneInformation", .f. )

nValor := oReg:Get( "Bias", 0 )
nValor := Round( nValor / 60, 0 ) * -1

oReg:Close()

cUTC := Left(Alltrim(Str(nValor)),1)+StrZero(Val(SubStr(Alltrim(Str(nValor)),2)),2)+":00"
EndIf

Return(cUTC)

Link to comment
Share on other sites

Em rWindows 7 de 32 bits, funciona de boa.



#include "FiveWin.ch"
#include "struct.ch"

#ifndef __XPP__
#define HKEY_CLASSES_ROOT 2147483648
#define HKEY_CURRENT_USER 2147483649
#define HKEY_LOCAL_MACHINE 2147483650
#define HKEY_USERS 2147483651
#define HKEY_PERFORMANCE_DATA 2147483652
#define HKEY_CURRENT_CONFIG 2147483653
#define HKEY_DYN_DATA 2147483654
#else
#define HKEY_CLASSES_ROOT 1
#define HKEY_CURRENT_USER 2
#define HKEY_LOCAL_MACHINE 3
#define HKEY_USERS 4
#define HKEY_PERFORMANCE_DATA 5
#define HKEY_CURRENT_CONFIG 6
#define HKEY_DYN_DATA 7
#endif

FUNCTION Main()

PRIV nTimez

nTimez := TimeZone()

? nTimez

RETURN NIL

FUNCTION TimeZOne()

LOCAL oReg, cUtc

oReg := TReg32():New(HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Control\TimeZoneInformation",.f.)

nTimez := oReg:Get( "Bias", 0 )
nTimez := Round( nTimez / 60, 0 ) * -1

cUTC := Left(Alltrim(Str(nTimez)),1)+StrZero(Val(SubStr(Alltrim(Str(nTimez)),2)),2)+":00"

nTimez := cUtc

oReg:Close()

RETURN( nTimez )

//-> FIM DO PROGRAMA


Abs


Link to comment
Share on other sites

bueno, talvez o problema seja com o 16 bits sei lá com win 8 e 8.1 foi de boa

oReg := TReg32():New( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\TimeZoneInformation" )
?nValor := oReg:Get( "Bias", 0 ) // RETORNO 180
?nValor := Round( nValor / 60, 0 ) * -1 // RETORNO -3
oReg:Close()
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...