Senhores boa tarde, porfa, alguém tem esta função completa para FiveWin for xHarbour, e em qualquer versão do windows e que possa disponibiliar?
Obg. abs.
Moderador: Moderadores
#pragma BEGINDUMP
#include <windows.h>
HB_FUNC( OS_ISUSERANADMIN )
{
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
b = AllocateAndInitializeSid( &NtAuthority, 2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup );
if( b )
{
if ( !CheckTokenMembership( NULL, AdministratorsGroup, &b ) )
b = FALSE;
FreeSid( AdministratorsGroup );
}
hb_retl( b );
}
#pragma ENDDUMP
#include "FiveWin.ch"
function Main()
If !WIN_OSNETREGOK() //Precisa direitos ADM
If !WIN_OSNETREGOK(.t.,.t.) //primeiro .t. é para ajustar XP/W98..., o segundo ajusta no vista.
MsgInfo('Registro do windows não ajustado !')
EndIf
EndIf
RETURN NIL
#include "common.ch"
#include "directry.ch"
#define WIN_HKEY_LOCAL_MACHINE 0
#define WIN_HKEY_CLASSES_ROOT 1
#define WIN_HKEY_CURRENT_USER 2
#define WIN_HKEY_CURRENT_CONFIG 3
#define WIN_HKEY_LOCAL_MACHINE 4
#define WIN_HKEY_USERS 5
/* NOTE: To change any of these registry settings
Administrator rights are required by default in Windows. [vszakats] */
FUNCTION WIN_OSNETREGOK( lSetIt, lDoVista )
LOCAL bRetVal := .T.
LOCAL cKeySrv
LOCAL cKeyWks
IF ! ISLOGICAL( lSetIt )
lSetIt := .F.
ENDIF
IF ! ISLOGICAL( lDoVista )
lDoVista := .T.
ENDIF
IF ! lDoVista .AND. Os_IsWinVISTA() //win_osIsVistaOrUpper()
/* do nothing */
ELSEIF Os_IsWin9X() // hb_osIsWin9x()
bRetVal := QueryRegistry( WIN_HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Services\VxD\VREDIR", "DiscardCacheOnOpen", 1, lSetIt )
ELSE
cKeySrv := "System\CurrentControlSet\Services\LanmanServer\Parameters"
cKeyWks := "System\CurrentControlSet\Services\LanmanWorkStation\Parameters"
IF lSetIt
lSetIt := ! Os_IsWinNT() .OR. os_IsUserAnAdmin() //wapi_IsUserAnAdmin()
ENDIF
/* Server settings */
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeySrv, "CachedOpenLimit", 0, lSetIt )
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeySrv, "EnableOpLocks", 0, lSetIt ) /* Q124916 */
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeySrv, "EnableOpLockForceClose", 1, lSetIt )
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeySrv, "SharingViolationDelay", 0, lSetIt )
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeySrv, "SharingViolationRetries", 0, lSetIt )
IF Os_IsWinVISTA() // win_osIsVistaOrUpper()
/* If SMB2 is enabled turning off oplocks does not work, so SMB2 is required to be turned off on Server. */
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeySrv, "SMB2", 0, lSetIt )
ENDIF
/* Workstation settings */
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeyWks, "UseOpportunisticLocking", 0, lSetIt )
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeyWks, "EnableOpLocks", 0, lSetIt )
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeyWks, "EnableOpLockForceClose", 1, lSetIt )
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeyWks, "UtilizeNtCaching", 0, lSetIt )
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeyWks, "UseLockReadUnlock", 0, lSetIt )
IF Os_IsWinVISTA() //win_osIsVistaOrUpper()
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeyWks, "FileInfoCacheLifetime", 0, lSetIt )
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeyWks, "FileNotFoundCacheLifetime", 0, lSetIt )
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, cKeyWks, "DirectoryCacheLifetime", 0, lSetIt )
ENDIF
IF Os_IsWinNT() //hb_osIsWin2K()
bRetVal := bRetVal .AND. QueryRegistry( WIN_HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Services\MRXSmb\Parameters", "OpLocksDisabled", 1, lSetIt )
ENDIF
// Itamar, nao precisa fazer isto no Windows 7 e 8?
IF Os_IsWin7() //hb_osIsWin7()
bRetVal := bRetVal ... ??? Entende?
ENDIF
IF Os_IsWin8() //hb_osIsWin8()
ENDIF
ENDIF
RETURN bRetVal
FUNCTION WIN_OSNETVREDIROK( /* @ */ nResult )
LOCAL aFiles
nResult := 0
IF Os_IsWin9X() // hb_osIsWin9x()
aFiles := Directory( GetEnv( "WINDIR", "C:\WINDOWS" ) + "\SYSTEM\VREDIR.VXD" ) /* Check for faulty files. */
IF ! Empty( aFiles )
IF aFiles[ 1 ][ F_SIZE ] == 156749 .AND. aFiles[ 1 ][ F_TIME ] == "11:11:10"
nResult := 1111
ELSEIF aFiles[ 1 ][ F_SIZE ] == 140343 .AND. aFiles[ 1 ][ F_TIME ] == "09:50:00"
nResult := 950
ENDIF
ENDIF
ENDIF
RETURN Empty( nResult )
#pragma BEGINDUMP
#include <windows.h>
HB_FUNC( OS_ISUSERANADMIN )
{
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
b = AllocateAndInitializeSid( &NtAuthority, 2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup );
if( b )
{
if ( !CheckTokenMembership( NULL, AdministratorsGroup, &b ) )
b = FALSE;
FreeSid( AdministratorsGroup );
}
hb_retl( b );
}
#pragma ENDDUMP
NT Networking & CA- Clipper ™
A família do sistema operacional baseado no Windows NT ® tem alguns problemas de estabilidade irritantes quando se lida com um legado DBMS de arquivos compartilhados , como CA- Clipper ™ . Esta página descreve esses aborrecimentos e tem soluções empacotadas como simples de usar. REG ( Registro) arquivos . Embora os links abaixo , muitas vezes só se referem a versões muito precoces de servidor NT , todos os comentários se aplicam a toda a linhagem até e incluindo Server 2008.
O problema básico é que a camada de redirecionamento de rede é muito "preguiçoso" em sua configuração padrão , quando se trata de escrever de volta imediatamente as alterações de dados para o sistema de arquivos do servidor subjacente. Embora esta abordagem não conferir alguns benefícios de velocidade , que também apresenta efeitos secundários indesejáveis . Estes efeitos colaterais muitas vezes se manifestam como " corrupção do índice detectado" mensagens de erro na aplicação Clipper ou (mais insidiosamente ) "perdido" de dados durante as atualizações de arquivos. Veja aqui para mais detalhes.
Outros problemas podem ser "desaparecimento " de unidades de rede (erro DOS 55 ) ea função dbuse () falha com " arquivo já está em uso" - veja aqui e aqui para mais detalhes.
Supressão de um fechado , mas, recentemente aberta, arquivo também pode falhar silenciosamente ( a exclusão parece funcionar , mas o arquivo ainda existe no servidor) . Veja aqui para mais detalhes.
AVISO - Usando o Editor do Registro incorretamente pode causar problemas sérios no sistema que talvez exijam a reinstalação do Windows para corrigi-los. Use essas ferramentas em seu próprio risco .
Abaixo estão dois arquivos . REG que podem ser usadas para alterar o comportamento do redirecionador de rede em servidores e estações de trabalho baseados no NT para permitir que aplicações Clipper para trabalhar de forma mais confiável . Para importar as mudanças no registro , basta fazer o download e , em seguida, clique duas vezes sobre o arquivo apropriado para importar para o registro. Note que você vai precisar para assegurar que você tenha os privilégios corretos (geralmente de administrador ou equivalente) , a fim de importar os arquivos de registro. . Após a reinicialização obrigatória , as novas configurações ficará ativo.
AVISO - . Ao clicar nos links abaixo reg pode tentar aplicar as alterações para o registro diretamente , então por favor clique com botão direito e use a opção "Salvar destino como ..." opção no seu browser.
* NEW *
28 de dezembro de 2004 - Adicionado chaves e comentários adicionais para os arquivos . Uma chave de registro adicional foi descoberto que afeta o Windows 2000 (que será ignorado no NT 4). Recomenda-se que os novos arquivos são aplicados a instalações utilizadas as versões anteriores .
18 de outubro de 2006 - Jean Mathieu de Outillage Placide Mathieu inc avistou um 'd' extra no final de " EnableOpLockForceClose " em NtWrkStn.reg - Agora corrigidos.
NTWrkStn.reg - modificações de registro para as estações de trabalho baseados no NT .
NTServer.reg - modificações de registro para servidores baseados em NT ( ou estações de trabalho que atuam como servidores) .
Nota: Estas alterações aplicam-se igualmente para o Windows ® NT 4, Windows ® 2000/2003/2008 e Windows ® XP, Vista e Windows 7
Ajuda adicional Clipper está disponível a partir de DaveP Clipper FAQ e VFAQ
Klas Engwall tem uma biblioteca livre útil para trabalhar com Clipper e redes Microsoft aqui
Para obter conselhos úteis sobre os problemas de configuração do Samba no Linux , veja aqui
********************
function TurbinaRede
********************
local oReg, aReg := { }
oReg := TReg32():New( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" )
aadd( aReg, { oReg:Get( "EnableOplocks" , "" ), "" } )
aadd( aReg, { oReg:Get( "CachedOpenLimit" , "" ), "" } )
aadd( aReg, { oReg:Get( "Autodisconnect" , "" ), "" } )
aadd( aReg, { oReg:Get( "EnableOplockForceClose", "" ), "" } )
aadd( aReg, { oReg:Get( "MaxKeepSearch" , "" ), "" } )
aadd( aReg, { oReg:Get( "MinKeepSearch" , "" ), "" } )
aadd( aReg, { oReg:Get( "ScavTimeout" , "" ), "" } )
aadd( aReg, { oReg:Get( "ThreadPriority" , "" ), "" } )
oReg:Set( "EnableOplocks" , "00000000" )
oReg:Set( "CachedOpenLimit" , "00000000" )
oReg:Set( "Autodisconnect" , "ffffffff" )
oReg:Set( "EnableOplockForceClose", "00000001" )
oReg:Set( "MaxKeepSearch" , "000000b4" )
oReg:Set( "MinKeepSearch" , "0000000a" )
oReg:Set( "ScavTimeout" , "0000000a" )
oReg:Set( "ThreadPriority" , "00000002" )
aReg [1,2] := oReg:Get( "EnableOplocks" , "" )
aReg [2,2] := oReg:Get( "CachedOpenLimit" , "" )
aReg [3,2] := oReg:Get( "Autodisconnect" , "" )
aReg [4,2] := oReg:Get( "EnableOplockForceClose", "" )
aReg [5,2] := oReg:Get( "MaxKeepSearch" , "" )
aReg [6,2] := oReg:Get( "MinKeepSearch" , "" )
aReg [7,2] := oReg:Get( "ScavTimeout" , "" )
aReg [8,2] := oReg:Get( "ThreadPriority" , "" )
oReg:Close()
oReg := NIL
return aReg
********************
function TurbinaRede
********************
local oReg, aReg := { }
if wapi_IsUserAnAdmin() // 30/08/18
VerKey( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\EnableOplocks" )
VerKey( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\CachedOpenLimit" )
VerKey( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Autodisconnect" )
VerKey( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\EnableOplockForceClose" )
VerKey( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\MaxKeepSearch" )
VerKey( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\MinKeepSearch" )
VerKey( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\ScavTimeout" )
VerKey( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\ThreadPriority" )
oReg := TReg32():New( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" )
aadd( aReg, { oReg:Get( "EnableOplocks" , "" ), "" } )
aadd( aReg, { oReg:Get( "CachedOpenLimit" , "" ), "" } )
aadd( aReg, { oReg:Get( "Autodisconnect" , "" ), "" } )
aadd( aReg, { oReg:Get( "EnableOplockForceClose", "" ), "" } )
aadd( aReg, { oReg:Get( "MaxKeepSearch" , "" ), "" } )
aadd( aReg, { oReg:Get( "MinKeepSearch" , "" ), "" } )
aadd( aReg, { oReg:Get( "ScavTimeout" , "" ), "" } )
aadd( aReg, { oReg:Get( "ThreadPriority" , "" ), "" } )
oReg:Set( "EnableOplocks" , "00000000" )
oReg:Set( "CachedOpenLimit" , "00000000" )
oReg:Set( "Autodisconnect" , "ffffffff" )
oReg:Set( "EnableOplockForceClose", "00000001" )
oReg:Set( "MaxKeepSearch" , "000000b4" )
oReg:Set( "MinKeepSearch" , "0000000a" )
oReg:Set( "ScavTimeout" , "0000000a" )
oReg:Set( "ThreadPriority" , "00000002" )
aReg [1,2] := oReg:Get( "EnableOplocks" , "" )
aReg [2,2] := oReg:Get( "CachedOpenLimit" , "" )
aReg [3,2] := oReg:Get( "Autodisconnect" , "" )
aReg [4,2] := oReg:Get( "EnableOplockForceClose", "" )
aReg [5,2] := oReg:Get( "MaxKeepSearch" , "" )
aReg [6,2] := oReg:Get( "MinKeepSearch" , "" )
aReg [7,2] := oReg:Get( "ScavTimeout" , "" )
aReg [8,2] := oReg:Get( "ThreadPriority" , "" )
oReg:Close()
oReg := NIL
else
aadd( aReg, { "EnableOplocks" , "Nao.Conf.Request ADM" } )
aadd( aReg, { "CachedOpenLimit" , "Nao.Conf.Request ADM" } )
aadd( aReg, { "Autodisconnect" , "Nao.Conf.Request ADM" } )
aadd( aReg, { "EnableOplockForceClose", "Nao.Conf.Request ADM" } )
aadd( aReg, { "MaxKeepSearch" , "Nao.Conf.Request ADM" } )
aadd( aReg, { "MinKeepSearch" , "Nao.Conf.Request ADM" } )
aadd( aReg, { "ScavTimeout" , "Nao.Conf.Request ADM" } )
aadd( aReg, { "ThreadPriority" , "Nao.Conf.Request ADM" } )
endif
return aReg
**********************
static function VerKey( nKey, cParameter ) // 30/08/18
**********************
local oReg
if !IsRegistryKey( nKey, cParameter )
oReg := TReg32():New( nKey, cParameter, .F. )
oReg:Create( nKey, cParameter )
oReg:Close()
endif
return IsRegistryKey( nKey, cParameter )
Usuários vendo este fórum: Nenhum usuário registrado online e 4 visitantes