conversione di Private Declare Function ShowWindow in PtrSafe

Stefano Colombo 0 Reputation points
2026-07-25T09:41:05.51+00:00

come converto questa funzione di Acces da Private Declare Function ShowWindow Lib "user32" _

(ByVal hWnd As Long, ByVal nCmdShow As Long) As Long in PtrSafe?

Developer technologies | Visual Basic for Applications

3 answers

Sort by: Oldest
  1. George Hepworth 23,120 Reputation points Volunteer Moderator
    2026-07-25T11:52:46.62+00:00

    Declare PtrSafe Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As LongPtr, ByVal nCmdShow As Long) As Long

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments

  2. eusebe miville 0 Reputation points
    2026-07-27T02:04:44.1133333+00:00

    Acceptées Recommandées

    Was this answer helpful?

    0 comments No comments

  3. Nancy Vo (WICLOUD CORPORATION) 8,155 Reputation points Microsoft External Staff Moderator
    2026-07-27T03:34:02.9166667+00:00

    Salve @Stefano Colombo ,

    Grazie per la domanda.

    Per convertire il codice per i nuovi sistemi a 64 bit, la parola chiave PtrSafe viene aggiunta alla dichiarazione e il parametro hWnd viene modificato da Long a LongPtr. Il tipo di dati LongPtr viene utilizzato per gestire indirizzi di memoria più ampi. Il parametro nCmdShow rimane Long perché rappresenta un valore standard, non un indirizzo di memoria.

    È possibile fare riferimento al seguente esempio di codice:

    Private Declare PtrSafe Function ShowWindow Lib "user32" _
    (ByVal hWnd As LongPtr, ByVal nCmdShow As Long) As Long
    

    Spero che questo risponda alla domanda. Se questa risposta è stata utile, si prega di considerare di seguire le linee guida per fornire un feedback. Grazie.

    Was this answer helpful?

    6 people found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.