Private Declare Function 64

💣 👉🏻👉🏻👉🏻 ALL INFORMATION CLICK HERE 👈🏻👈🏻👈🏻
Yes
No
Used at the module level to declare references to external procedures in a dynamic-link library (DLL).
Declare statements with the PtrSafe keyword is the recommended syntax. Declare statements that include PtrSafe work correctly in the VBA version 7 development environment on both 32-bit and 64-bit platforms only after all data types in the Declare statement (parameters and return values) that need to store 64-bit quantities are updated to use LongLong for 64-bit integrals or LongPtr for pointers and handles. To ensure backwards compatibility with VBA version 6 and earlier, use the following construct:
[ Public | Private ] Declare Sub name Lib " libname " [ Alias " aliasname " ] [ ( [ arglist ] ) ]
[ Public | Private ] Declare Function name Lib " libname " [ Alias " aliasname " ] [ ( [ arglist ] ) ] [ As type ]
For code to run in 64-bit versions of Microsoft Office, all Declare statements must include the PtrSafe keyword, and all data types in the Declare statement (parameters and return values) that need to store 64-bit quantities must be updated to use LongLong for 64-bit integrals or LongPtr for pointers and handles.
[ Public | Private ] Declare PtrSafe Sub name Lib " libname " [ Alias " aliasname " ] [ ( [ arglist ] ) ]
[ Public | Private ] Declare PtrSafe Function name Lib " libname " [ Alias " aliasname " ] [ ( [ arglist ] ) ] [ As type ]
The arglist argument has the following syntax and parts:
[ Optional ] [ ByVal | ByRef ] [ ParamArray ] varname [ ( ) ] [ As type ]
If you include an argument list, the number and type of arguments are checked each time the procedure is called. The following example takes one Long argument:
This example shows how the Declare statement is used at the module level of a standard module to declare a reference to an external procedure in a dynamic-link library (DLL). You can place the Declare statements in class modules if the Declare statements are Private .
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Optional. Used to declare procedures that are available to all other procedures in all modules .
Optional. Used to declare procedures that are available only within the module where the declaration is made.
Required on 64-bit. The PtrSafe keyword asserts that a Declare statement is safe to run in 64-bit versions of Microsoft Office.
Optional (either Sub or Function must appear). Indicates that the procedure doesn't return a value.
Optional (either Sub or Function must appear). Indicates that the procedure returns a value that can be used in an expression .
Required. Any valid procedure name. Note that DLL entry points are case-sensitive.
Required. Indicates that a DLL or code resource contains the procedure being declared. The Lib clause is required for all declarations.
Required. Name of the DLL or code resource that contains the declared procedure.
Optional. Indicates that the procedure being called has another name in the DLL. This is useful when the external procedure name is the same as a keyword. You can also use Alias when a DLL procedure has the same name as a public variable , constant , or any other procedure in the same scope . Alias is also useful if any characters in the DLL procedure name aren't allowed by the DLL naming convention.
Optional. Name of the procedure in the DLL or code resource. If the first character is not a number sign ( # ), aliasname is the name of the procedure's entry point in the DLL. If ( # ) is the first character, all characters that follow must indicate the ordinal number of the procedure's entry point.
Optional. List of variables representing arguments that are passed to the procedure when it is called.
Optional. Data type of the value returned by a Function procedure; may be Byte , Boolean , Integer , Long , LongLong , LongPtr , Currency , Single , Double , Decimal (not currently supported), Date , String (variable length only), Variant , a user-defined type , or an object type . ( LongLong is a valid declared type only on 64-bit platforms.)
Optional. Indicates that an argument is not required. If used, all subsequent arguments in arglist must also be optional and declared by using the Optional keyword. Optional can't be used for any argument if ParamArray is used.
Optional. Indicates that the argument is passed by value .
Indicates that the argument is passed by reference . ByRef is the default in Visual Basic.
Optional. Used only as the last argument in arglist to indicate that the final argument is an Optional array of Variant elements. The ParamArray keyword allows you to provide an arbitrary number of arguments. The ParamArray keyword can't be used with ByVal , ByRef , or Optional .
Required. Name of the variable representing the argument being passed to the procedure; follows standard variable naming conventions.
Required for array variables. Indicates that varname is an array.
Optional. Data type of the argument passed to the procedure; may be Byte , Boolean , Integer , Long , LongLong , LongPtr , Currency , Single , Double , Decimal (not currently supported), Date , String (variable length only), Object , Variant , a user-defined type, or an object type. ( LongLong is a valid declared type only on 64-bit platforms.)
This site uses cookies to analyse traffic and remember your preferences.
Home > Article index > add-in Installation Add-ins do not load API declarations Build Excel Add-in Catch Paste Chart an Equation Challenges Circular References Co-Authoring Control Events Controls Corrupt Files Create add-ins Custom Find Data Types Data Entry Help Defined Names Disable Events Docking VBE Windows Excel 2007 FileFormat Drag And Drop Excel data table recipe Excel Tables Excel Tables (VBA) Excel Web App Mashups Fix Links to UDFs Formula Wrapper Import textfiles Inventory System Keep Userform On Top Lambda function basics Lambda From VBA Listbox AutoSize Least Squares Object Lister Office Script basics Office Script examples Pivottable Slicers Performance Class Prevent Open Event Register UDFs Remove Add-in Round2Digits Select a range (VBA) Self installing Add-in Show Picture Spreadsheet Template Startup Problems Styles in Excel Transpose Table Treeview control Undo With Excel VBA Update An add-in WebQuery Wheel of Fortune Workbook Open Bug XML and Excel
Declare PtrSafe Function
CloseClipboard Lib "User32" ()
As LongPtr
Declare Function
CloseClipboard Lib "User32" ()
As Long
#If VBA7 Then Public Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ ( ByRef destination As Any, ByRef SOURCE As Any, ByVal Length As LongPtr) #Else Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ ( ByRef destination As Any, ByRef SOURCE As Any, ByVal Length As Long ) # End If
Declare Function
CreateProcess Lib "kernel32" _
Alias "CreateProcessA" ( ByVal lpApplicationName
As String , _
ByVal lpCommandLine As
String , _
lpProcessAttributes As SECURITY_ATTRIBUTES,
_
lpThreadAttributes As SECURITY_ATTRIBUTES,
_
ByVal bInheritHandles As
Long , _
ByVal dwCreationFlags As
Long , _
lpEnvironment As Any, _
ByVal lpCurrentDriectory
As String , _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION)
As Long
Declare PtrSafe
Function CreateProcess Lib "kernel32"
_
Alias "CreateProcessA" ( ByVal lpApplicationName
As String , _
ByVal lpCommandLine As
String , _
lpProcessAttributes As SECURITY_ATTRIBUTES,
_
lpThreadAttributes As SECURITY_ATTRIBUTES,
_
ByVal bInheritHandles As
Long , _
ByVal dwCreationFlags As
Long , _
lpEnvironment As Any, _
ByVal lpCurrentDriectory
As String , _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION)
As LongPtr
'Full example shown below, including the necessary structures
#If VBA7 Then
Declare PtrSafe
Function CreateProcess Lib "kernel32"
_
Alias "CreateProcessA" ( ByVal lpApplicationName
As String , _
ByVal lpCommandLine As
String , _
lpProcessAttributes As SECURITY_ATTRIBUTES,
_
lpThreadAttributes As SECURITY_ATTRIBUTES,
_
ByVal bInheritHandles As
Long , _
ByVal dwCreationFlags As
Long , _
lpEnvironment As Any, _
ByVal lpCurrentDriectory
As String , _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION)
As LongPtr
Const INFINITE = &HFFFF
Const STARTF_USESHOWWINDOW = &H1
Private Enum enSW
SW_HIDE = 0
SW_NORMAL = 1
SW_MAXIMIZE = 3
SW_MINIMIZE = 6
End Enum
Private Type PROCESS_INFORMATION
hProcess As LongPtr
hThread As LongPtr
dwProcessId As Long
dwThreadId As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As
Long
dwYCountChars As
Long
dwFillAttribute As
Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As LongPtr
hStdOutput As LongPtr
hStdError As LongPtr
End Type
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As
LongPtr
bInheritHandle As
Long
End Type
Private Enum enPriority_Class
NORMAL_PRIORITY_CLASS = &H20
IDLE_PRIORITY_CLASS = &H40
HIGH_PRIORITY_CLASS = &H80
End Enum
#Else
Declare Function
CreateProcess Lib "kernel32" _
Alias "CreateProcessA" ( ByVal lpApplicationName
As String , _
ByVal lpCommandLine As
String , _
lpProcessAttributes As SECURITY_ATTRIBUTES,
_
lpThreadAttributes As SECURITY_ATTRIBUTES,
_
ByVal bInheritHandles As
Long , _
ByVal dwCreationFlags As
Long , _
lpEnvironment As Any, _
ByVal lpCurrentDriectory
As String , _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION)
As Long
Const INFINITE = &HFFFF
Const STARTF_USESHOWWINDOW = &H1
Private Enum enSW
SW_HIDE = 0
SW_NORMAL = 1
SW_MAXIMIZE = 3
SW_MINIMIZE = 6
End Enum
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As
Long
dwYCountChars As
Long
dwFillAttribute As
Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As
Long
bInheritHandle As Long
End Type
Private Enum enPriority_Class
NORMAL_PRIORITY_CLASS = &H20
IDLE_PRIORITY_CLASS = &H40
HIGH_PRIORITY_CLASS = &H80
End Enum
# End If
Private Function
SuperShell( ByVal App As
String , ByVal WorkDir
As String , dwMilliseconds
As Long , _
ByVal start_size As
enSW, ByVal Priority_Class
As enPriority_Class) As
Boolean
Dim pclass As
Long
Dim sinfo As
STARTUPINFO
Dim pinfo As
PROCESS_INFORMATION
'Not used, but needed
Dim sec1 As
SECURITY_ATTRIBUTES
Dim sec2 As
SECURITY_ATTRIBUTES
'Set the structure size
sec1.nLength = Len(sec1)
sec2.nLength = Len(sec2)
sinfo.cb = Len(sinfo)
'Set the flags
sinfo.dwFlags = STARTF_USESHOWWINDOW
'Set the window's startup position
sinfo.wShowWindow = start_size
'Set the priority class
pclass = Priority_Class
'Start the program
If CreateProcess(vbNullString, App,
sec1, sec2, False , pclass, _
0&, WorkDir, sinfo, pinfo) Then
'Wait
' WaitForSingleObject pinfo.hProcess,
dwMilliseconds
SuperShell = True
Else
SuperShell = False
End If
End Function
Sub Test()
Dim sFile As
String
'Set the dialog's title
sFile = Application.GetOpenFilename("Executables (*.exe), *.exe",
, "")
SuperShell sFile, Left(sFile, InStrRev(sFile, "\")), 0, SW_NORMAL,
HIGH_PRIORITY_CLASS
End Sub
#If VBA7 Then
Public Declare
PtrSafe Function DrawMenuBar
Lib "user32" ( ByVal
hWnd As LongPtr) As
Long
#Else
Public Declare
Function DrawMenuBar Lib
"user32" ( ByVal hWnd As
Long ) As Long
# End If
Declare PtrSafe Function
EmptyClipboard Lib "User32" ()
As Long Ptr
Declare Function
EmptyClipboard Lib "User32" ()
As Long
Private Declare
Function FindWindow Lib
"USER32" Alias "FindWindowA" ( ByVal lpClassName
As String ,
ByVal lpWindowName As
String ) As
Long
Private Declare PtrSafe
Function FindWindow Lib
"USER32" Alias "FindWindowA" ( ByVal lpClassName
As String ,
ByVal lpWindowName As
String ) As LongPtr
Private Declare
Function FindWindowEx Lib
"USER32" _
Alias "FindWindowExA" ( ByVal hWnd1
As Long ,
ByVal hWnd2 As
Long , _
ByVal lpsz1 As
String , ByVal lpsz2
As String )
As Long
Private Declare PtrSafe
Function FindWindowEx Lib
"USER32" _
Alias "FindWindowExA" ( ByVal hWnd1
As LongPtr , ByVal hWnd2
As LongPtr , _
ByVal lpsz1 As
String , ByVal lpsz2
As String )
As LongPtr
Private Declare
Function GdipCreateBitmapFromFile
Lib "GDIPlus" ( ByVal
filename As Long , bitmap
As Long )
As Long
Private Declare PtrSafe
Function GdipCreateBitmapFromFile
Lib "GDIPlus" ( ByVal
filename As LongPtr, bitmap
As LongPtr) As LongPtr
Private Declare
Function GdipCreateHBITMAPFromBitmap
Lib "GDIPlus" ( ByVal
bitmap As Long , hbmReturn
As Long ,
ByVal background As
Long ) As
Long
Private Declare PtrSafe
Function GdipCreateHBITMAPFromBitmap
Lib "GDIPlus" ( ByVal
bitmap As LongPtr, hbmReturn
As Long Ptr,
ByVal background As
Long) As LongPtr
Private Declare
Function GdipDisposeImage Lib
"GDIPlus" ( ByVal image As
Long ) As
Long
Private Declare PtrSafe
Function GdipDisposeImage Lib
"GDIPlus" ( ByVal image As
LongPtr) As LongPtr
Private Declare
Function GdiplusShutdown Lib
"GDIPlus" ( ByVal token As
Long ) As
Long
Private Decla
https://docs.microsoft.com/en-us/office/vba/Language/Reference/user-interface-help/declare-statement
https://jkp-ads.com/Articles/apideclarations.asp
Lesbian Chat Room
Xxx Video Brat Zastavila Sasat Devushka
Old Mature Share
Declare statement (VBA) | Microsoft Docs
Excel: Declaring API functions in 64 bit Office
VBA Functions in 64-Bit Versions - Oracle
Declaring API functions in 32 or 64 bits
32 Bit And 64 Bit Api Declarations For Vba Developers ...
Declare 语句 (VBA) | Microsoft Docs
解决 vba 报错:要在64位系统上使用,请检查并更新Declare …
Declaring API Functions In 64 Bit Office | NS4B
Private Declare Function 64







































