MaximoAccess

Caro Usuário, antes de postar pela primeira vez, leia as regras do fórum.

https://www.maximoaccess.com/t48-regras-do-forum

Obrigado

Administração


Participe do fórum, é rápido e fácil

MaximoAccess

Caro Usuário, antes de postar pela primeira vez, leia as regras do fórum.

https://www.maximoaccess.com/t48-regras-do-forum

Obrigado

Administração

MaximoAccess

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Dicas Ms Access, Exemplos Ms Access, Codigos VBA Ms Access, SQL Ms Access


2 participantes

    [Resolvido]Erro access 64 bits

    fernando rodrigo zanchini
    fernando rodrigo zanchini
    Intermediário
    Intermediário


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 198
    Registrado : 18/04/2018

    [Resolvido]Erro access 64 bits Empty [Resolvido]Erro access 64 bits

    Mensagem  fernando rodrigo zanchini 15/3/2020, 22:20

    Boa noite instalei o access 64 bits e onde tem Private Declare coloquei PtrSafe Function só que
    esta dando um erro neste comando "AddressOf NewProc"


    Private Declare PtrSafe Function CallNextHookEx _
    Lib "User32" ( _
    ByVal hHook As Long, _
    ByVal ncode As Long, _
    ByVal wParam As Long, _
    LParam As Any) _
    As Long

    Private Declare PtrSafe Function GetModuleHandle _
    Lib "kernel32" _
    Alias "GetModuleHandleA" ( _
    ByVal lpModuleName As String) _
    As Long

    Private Declare PtrSafe Function SetWindowsHookEx _
    Lib "User32" _
    Alias "SetWindowsHookExA" ( _
    ByVal idHook As Long, _
    ByVal lpfn As Long, _
    ByVal hmod As Long, _
    ByVal dwThreadId As Long) _
    As Long

    Private Declare PtrSafe Function UnhookWindowsHookEx _
    Lib "User32" ( _
    ByVal hHook As Long) _
    As Long

    Private Declare PtrSafe Function SendDlgItemMessage _
    Lib "User32" Alias "SendDlgItemMessageA" ( _
    ByVal hDlg As Long, _
    ByVal nIDDlgItem As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByVal LParam As Long) _
    As Long

    Private Declare PtrSafe Function GetClassName _
    Lib "User32" _
    Alias "GetClassNameA" ( _
    ByVal hWnd As Long, _
    ByVal lpClassName As String, _
    ByVal nMaxCount As Long) _
    As Long

    Private Declare PtrSafe Function GetCurrentThreadId _
    Lib "kernel32" () _
    As Long


    Private Const EM_SETPASSWORDCHAR = &HCC
    Private Const WH_CBT = 5
    Private Const HCBT_ACTIVATE = 5
    Private Const HC_ACTION = 0

    Private hHook As Long

    Public Function NewProc(ByVal lngCode As Long, _
    ByVal wParam As Long, _
    ByVal LParam As Long) As Long

    Dim RetVal
    Dim strClassName As String, lngBuffer As Long

    If lngCode < HC_ACTION Then
    NewProc = CallNextHookEx(hHook, lngCode, wParam, LParam)
    Exit Function

    End If

    strClassName = String$(256, " ")
    lngBuffer = 255

    If lngCode = HCBT_ACTIVATE Then 'A window has been activated
    RetVal = GetClassName(wParam, strClassName, lngBuffer)
    If Left$(strClassName, RetVal) = "#32770" Then 'Class name of the Inputbox

    SendDlgItemMessage wParam, &H1324, EM_SETPASSWORDCHAR, Asc("*"), &H0
    End If
    End If


    CallNextHookEx hHook, lngCode, wParam, LParam

    End Function



    Public Function InputBoxDK(Prompt As String, Optional Title As String, _
    Optional Default As String, _
    Optional Xpos As Long, _
    Optional Ypos As Long, _
    Optional Helpfile As String, _
    Optional Context As Long) As String

    Dim lngModHwnd As Long, lngThreadID As Long


    On Error GoTo ExitProperly
    lngThreadID = GetCurrentThreadId
    lngModHwnd = GetModuleHandle(vbNullString)


    hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)
    If Xpos Then
    InputBoxDK = InputBox(Prompt, Title, Default, Xpos, Ypos, Helpfile, Context)
    Else
    InputBoxDK = InputBox(Prompt, Title, Default, , , Helpfile, Context)
    End If

    ExitProperly:
    UnhookWindowsHookEx hHook

    End Function

    DamascenoJr.
    DamascenoJr.
    Moderador
    Moderador


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 3845
    Registrado : 22/11/2016

    [Resolvido]Erro access 64 bits Empty Re: [Resolvido]Erro access 64 bits

    Mensagem  DamascenoJr. 15/3/2020, 23:33

    Não é só o PtrSafe, veja o trecho sobre as API's do artigo do link abaixo
    usandoaccess.com.br/tutoriais/configurar-api-access-de-64-e-32-bits-ptrsafe.asp?id=1

    UsandoAccess escreveu:Mudanças nas APIs

    Todas as APIs utilizadas com o Office 2010 sofreram alterações na sua estrutura para atender a versão de 64 bits. Foram acrescentados o atributo PtrSafe, na instrução declare e os novos tipos de dados LongLong e LongPtr.

    Para o office 2010 de 32 bits a API funciona sem precisar realizar qualquer alteração, porém a Microsoft recomenda que se use com o atributo Ptrsafe:

    Declare ptrsafe Function GetActiveWindow Lib "user32" () As Long

    Para atender a versão de 64 bits é preciso alterar o tipo long para longPtr que também é aceito no Access 2010 de 32 bits:

    Declare ptrsafe Function GetActiveWindow Lib "user32" () As LongPtr


    Segue a função tanto para 32 bits quando para 64 bits
    Código:
    #If VBA7 Then

        Private Declare PtrSafe Function CallNextHookEx Lib "user32" (ByVal hHook As LongPtr, ByVal ncode As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
        Private Declare PtrSafe Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As LongPtr
        Private Declare PtrSafe Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As LongPtr, ByVal hmod As LongPtr, ByVal dwThreadId As Long) As LongPtr
        Private Declare PtrSafe Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As LongPtr) As Long
        Private Declare PtrSafe Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" (ByVal hDlg As LongPtr, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
        Private Declare PtrSafe Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As LongPtr, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
        Private Declare PtrSafe Function GetCurrentThreadId Lib "kernel32" () As Long
       
        Private hHook As LongPtr

        Private Function NewProc(ByVal lngCode As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPtr
           
            Dim strClassName As String
       
            If lngCode < 0 Then
                NewProc = CallNextHookEx(hHook, lngCode, wParam, lParam)
                Exit Function
            End If
       
            strClassName = String$(256, " ")
       
            If lngCode = 5 Then _
                If Left$(strClassName, GetClassName(wParam, strClassName, 255)) = "#32770" Then _
                    SendDlgItemMessage wParam, &H1324, &HCC, Asc("*"), &H0
       
            Call CallNextHookEx(hHook, lngCode, wParam, lParam)
       
        End Function
       
    #Else

        Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
        Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
        Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
        Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
        Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
        Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
       
        Private hHook As Long

        Private Function NewProc(ByVal lngCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
           
            Dim strClassName As String
       
            If lngCode < 0 Then
                NewProc = CallNextHookEx(hHook, lngCode, wParam, lParam)
                Exit Function
            End If
       
            strClassName = String$(256, " ")
       
            If lngCode = 5 Then _
                If Left$(strClassName, GetClassName(wParam, strClassName, 255)) = "#32770" Then _
                    SendDlgItemMessage wParam, &H1324, &HCC, Asc("*"), &H0
       
            Call CallNextHookEx(hHook, lngCode, wParam, lParam)
       
        End Function
       
    #End If

    Public Function InputBoxDK(Prompt, Optional Title, Optional Default, Optional XPos, Optional YPos, Optional HelpFile, Optional Context) As String
       
        hHook = SetWindowsHookEx(5, AddressOf NewProc, GetModuleHandle(vbNullString), GetCurrentThreadId)
        InputBoxDK = InputBox(Prompt, Title, Default, XPos, YPos, HelpFile, Context)
        Call UnhookWindowsHookEx(hHook)

    End Function


    .................................................................................
    Ajude-se a ser ajudado, anexe seu projeto.
    Sempre tente entender o código,
    não somente copie e cole.
    Positive as mensagens que achar útil clicando no '+' no canto superior direito delas.
    fernando rodrigo zanchini
    fernando rodrigo zanchini
    Intermediário
    Intermediário


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 198
    Registrado : 18/04/2018

    [Resolvido]Erro access 64 bits Empty Re: [Resolvido]Erro access 64 bits

    Mensagem  fernando rodrigo zanchini 16/3/2020, 11:17

    Bom Dia Deu Certo
    Obrigado cheers cheers
    DamascenoJr.
    DamascenoJr.
    Moderador
    Moderador


    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 3845
    Registrado : 22/11/2016

    [Resolvido]Erro access 64 bits Empty Re: [Resolvido]Erro access 64 bits

    Mensagem  DamascenoJr. 16/3/2020, 20:42

    O fórum agradece o retorno. Sucesso.


    .................................................................................
    Ajude-se a ser ajudado, anexe seu projeto.
    Sempre tente entender o código,
    não somente copie e cole.
    Positive as mensagens que achar útil clicando no '+' no canto superior direito delas.

    Conteúdo patrocinado


    [Resolvido]Erro access 64 bits Empty Re: [Resolvido]Erro access 64 bits

    Mensagem  Conteúdo patrocinado


      Data/hora atual: 15/7/2024, 15:07