1. 아별툴
  2. 아별툴 패밀리
  3. 엑셀 질문하기
  4. 엑셀 강좌
  5. 엑셀 팁
  6. 엑셀 자료실
  7. 엑셀 연구과제
  8. 엑셀 북마크
  9. 관련 프로그램 소개

오피스2010 64bit(64비트)를 위한 API Declare 방법

기타 조회 수 9218 추천 수 0 2011.10.05 02:44:01

<< 이 강좌는 오른쪽 링크의 강좌와 연계돼 있습니다.  http://www.abyul.com/zbxe/138852 >>


예전에 적어놨던 거 같은데.. 없네요? ^_^:;

못 찾는건가.. 이 넘의 홈페이지가 구조가 너무 지랄 맞아서.. ㅎㅎ

 

암튼.. 정리합니다.

 

MS 오피스에 64비트 버전이 생기면서 여러가지가 달라졌지만..

엑셀 추가기능을 개발하는 입장에서는 API선언이 좀 귀찮아진게 가장 표면적으로 와 닿는 문제네요..

 

VBE(Visual Basic Editor)창에서 F1눌러서 도움말 창을 띄우신 다음,

검색란에 "64비트"로 검색해보시면 많은 정보를 얻으실 수 있을 겁니다.

 

그 중에서 "64비트 Visual Basic for Applications 개요"라는 도움말이 제일 맘에 드네요.

그건 각자 검색해보시구요.. ^^

여기다 카피해 넣어봤자 의미가 없을 것 같구요.. 제 나름 설명을 하자면..

 

1. 일반적인 32비트 코드도 64비트에서 에러가 안납니다.

2. 에러는 Windows API를 호출하는 Declare문에서 발생합니다.

3. 예를 들어보겠습니다.

   활성창의 핸들값을 갖고 오는 GetActiveWindows라는 API를 선언해보겠습니다.

 

[ 32비트에서는 아래처럼 선언했었죠.. ]

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

 

[ 64비트에서는 아래처럼 선언해야합니다. ]

Private Declare PtrSafe Function GetActiveWindow Lib "user32" () As LongPtr

 

도움말을 참조하자면..

PtrSafe : PtrSafe 키워드는 64비트 버전의 Office에서 Declare 문이 안전하게 실행됨을 나타냅니다.

LongPtr : VBA에 변수 형식의 별칭 LongPtr이 추가되었습니다. LongPtr이 확인되는 실제 데이터 형식은 실행 중인 Office 버전에 따라 다릅니다. 32비트 버전의 Office에서는 LongPtrLong으로 확인되고, 64비트 버전의 Office에서는 LongPtrLongLong으로 확인됩니다. LongPtr은 포인터 및 핸들에 사용됩니다

 

그냥 64비트만 사용한다고 하면.. 위 선언문의 LongPtr은 LongLong로 바꾸셔도 됩니다만..

확장성 없이 코딩하는 건 좀 아마추어같죠.. ㅎㅎ

 

그리하여...

32비트와 64비트에서 모두 사용할 수 있는 코드를 작성해보겠습니다.

  

#If VBA7 Then
     #If Win64 Then
          Private Declare PtrSafe Function GetActiveWindow Lib "user32" () As LongPtr
     #Else
          Private Declare Function GetActiveWindow Lib "user32" () As Long
     #End If
#Else
     Private Declare Function GetActiveWindow Lib "user32" () As Long
#End If

 

[ 설명 ]

#If...Then...#Else 지시문은 Visual Basic 코드 중 선택된 블록들만 조건부로 컴파일합니다.

라고 도움말에 나와 있습니다.

"#IF"를 검색해보시면 관련 도움말이 나옵니다.

시스템의 사양에 따라서 해당하는 코드만 컴파일해서 실행한다는 얘기죠..

VBA7 은 컴파일러 상수라고 해서.. 시스템에 따라서 True 또는 False 값을 갖습니다.

 

오피스 2010에선 VBA7이 True값을 갖지만.. 그 하위 버전의 엑셀에서는 False 값을 갖습니다.

비슷하게 VBA6, WIN32, WIN64 같은게 있습니다. 코드가 실행되는 시스템에 따라, TRUE 또는 FALSE 값을 갖지요..

 

위 선언문을 좀 요약하면 아래와 같습니다.

좀 알아보기 쉬워졌죠?

 

#If VBA7 Then
     #If Win64 Then
           오피스 2010이면서 64비트 일때 선언할 선언문..
     #Else
          오피스 2010이지만 64비트가 아닐때.. 즉 32비트일때의 선언문..

     #End If
#Else
     그렇지 않은 경우.. 오피스 2007이나 2003 또는 이하 버전..
#End If

 

어차피 현재 64비트 오피스는 엑셀2010뿐이니까..

아래처럼 간략하게 작성해도 됩니다.

 

#If Win64 Then
      64비트 일때 선언할 선언문..
#Else
      그렇지 않은 경우.. 오피스 2010 32비트나.. 오피스 2007이나 2003 또는 이하 버전..
#End If

 

 

이때 유의해야할게..

 

1. 오피스 2010이면서 64비트일때의 선언문을 작성할때에는..

     Declare 단어 뒤에 PtrSafe를 삽입해주시구요.. 결과값이 Long 형이라면 LongPtr 형으로 변경해줍니다.

 

2. API의 결과물을 사용하는 변수형도 LongPtr로 선언해주셔야겠죠?

     아니면 강제로 Long형으로 변환해버리는 CLng()를 사용하셔야합니다.

     훨씬 큰 숫자 범위를 갖는 LongLong형을 작은 범위를 갖는 Long형에 때려 넣기 때문에..

      결과값이 Long의 숫자 범위를 벗어나는 숫자였다면 정보가 유실되어 버리겠죠?.. 이것만 주의하시면 됩니다.

 

 

머.. 새벽에 주저리 주저리 작성해서 도움이 되실지.. ㅎㅎ

졸리네요.. ^_^;;

 

잘 이해 안가시면 댓글 남기세요..

보강해드리겠습니다.

 

 

즐거운 하루 보내세요.. ^^)/ 

 

참고로..

VB전처리구문에 대한 자세한 설명은 아래 카페의 게시물을 참고하세요...

http://cafe.naver.com/xlsvba/3439

 

참고로..

네이버 클럽.. 엑셀 하루에 하나씩에서 활동중이신 리에님이 공개해주신 컬러픽커 클래스를

64비트 엑셀 2010에서도 사용할 수 있도록 수정한 파일을 공유합니다.

실제 적용예를 파일로 보시는게 확실할 것 같아 올려놓습니다.

다운 받기 : VBA_API__ColorPicker_For_64bit.xlsm

 


[ 참고사이트 ]

1. MSDN Office 2010 32비트 버전과 64비트 버전 간의 호환성

2. MS에서 제공하는 Help파일 다운로드 : Win32 API를 64비트로 선언하는 방법과 상수들 목록이 있다.

   http://www.microsoft.com/download/en/confirmation.aspx?id=9970

   위 사이트에 들어가면 "Office2010Win32API_PtrSafe.exe"을 다운 받을 수 있다.

   실행파일이라 다운 받기 그러면.. 이글에 첨부된 "Win32API_PtrSafe.TXT" 파일을 다운 받아도 된다.




댓글 '2'

지일

2016.08.26 16:03:44
*.175.9.103

감사합니다 ^_^

profile

[레벨:30]아별

2017.04.06 23:42:35
*.87.69.143

많이 사용하는 API함수를 64비트에서 사용할 수 있도록 코드를 제공한 사이트가 있어 링크합니다.

From. http://www.jkp-ads.com/articles/apideclarations.asp


FindWindow
Private Declare Function FindWindow Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As StringByVallpWindowName As StringAs Long

Private
 Declare PtrSafe Function FindWindow Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String,ByVal lpWindowName As StringAs LongPtr
FindWindowEx
Private Declare Function FindWindowEx Lib "USER32" _
                                  Alias "FindWindowExA" (ByVal hWnd1 As LongByVal hWnd2 As Long, _
                                  ByVal lpsz1 As StringByVal lpsz2 As StringAs Long

Private
 Declare PtrSafe Function FindWindowEx Lib "USER32" _
                                  Alias "FindWindowExA" (ByVal hWnd1 As LongPtrByVal hWnd2 As LongPtr, _
                                  ByVal lpsz1 As StringByVal lpsz2 As StringAs LongPtr
GdipCreateBitmapFromFile
Private Declare Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal filename As Long, bitmap As LongAsLong

Private Declare PtrSafe Function GdipCreateBitmapFromFile Lib "GDIPlus" (ByVal filename As LongPtr, bitmapAs LongPtr) As LongPtr
GdipCreateHBITMAPFromBitmap
Private Declare Function GdipCreateHBITMAPFromBitmap Lib "GDIPlus" (ByVal bitmap As Long, hbmReturn As Long,ByVal background As LongAs Long

Private Declare PtrSafe Function GdipCreateHBITMAPFromBitmap Lib "GDIPlus" (ByVal bitmap As LongPtr, hbmReturn As LongPtr, ByVal background As Long) As LongPtr
GdipDisposeImage
Private Declare Function GdipDisposeImage Lib "GDIPlus" (ByVal image As LongAs Long

Private Declare PtrSafe Function GdipDisposeImage Lib "GDIPlus" (ByVal image As LongPtr) As LongPtr
GdiplusShutdown
Private Declare Function GdiplusShutdown Lib "GDIPlus" (ByVal token As LongAs Long

Private Declare PtrSafe Function GdiplusShutdown Lib "GDIPlus" (ByVal token As LongPtr) As LongPtr
GdiplusStartup
Private Declare Function GdiplusStartup Lib "GDIPlus" (token As Long, inputbuf As GdiplusStartupInput,Optional ByVal outputbuf As Long = 0) As Long
Private Type GdiplusStartupInput
    GdiplusVersion As Long
    DebugEventCallback As Long
    SuppressBackgroundThread As Long
    SuppressExternalCodecs As Long
End Type
    
Private Declare PtrSafe Function GdiplusStartup Lib "GDIPlus" (token As LongPtr, inputbuf AsGdiplusStartupInput, Optional ByVal outputbuf As LongPtr = 0) As LongPtr

Private Type GdiplusStartupInput
    GdiplusVersion As Long
    DebugEventCallback As LongPtr
    SuppressBackgroundThread As Long
    SuppressExternalCodecs As Long
End Type
GetClassName
Public Declare Function GetClassName Lib "USER32" Alias "GetClassNameA" _
                                     (ByVal hWnd As Long, ByVal lpClassName As String, _
                                      ByVal nMaxCount As LongAs Long

Public Declare PtrSafe Function GetClassName Lib "USER32" Alias "GetClassNameA" _
                                     (ByVal hWnd As LongPtrByVal lpClassName As String, _
                                      ByVal nMaxCount As LongPtrAs Long
GetDiskFreeSpaceEx
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
    Alias "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, _
    lpFreeBytesAvailableToCaller As Currency, _
    lpTotalNumberOfBytes As Currency, _
    lpTotalNumberOfFreeBytes As CurrencyAs Long
Private Declare PtrSafe Function GetDiskFreeSpaceEx Lib "kernel32" Alias _
    "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, _
    lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As _
    Currency, lpTotalNumberOfFreeBytes As CurrencyAs LongPtr
getDC
Private Declare Function GetDC Lib "USER32" (ByVal hWnd As LongAs Long

Private
 Declare PtrSafe Function GetDC Lib "USER32" (ByVal hWnd As LongPtrAs LongPtr
GetDesktopWindow
Public Declare Function GetDesktopWindow Lib "USER32" () As Long

Public Declare PtrSafe Function GetDesktopWindow Lib "USER32" () As LongPtr
getDeviceCaps
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As LongByVal nIndex As LongAs Long

Private
 Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hDC As LongPtrByVal nIndex As LongAsLong
GetDriveType
Private Declare Function GetDriveType Lib "kernel32" Alias _
                        "GetDriveTypeA" (ByVal sDrive As StringAs Long

Private Declare PtrSafe Function GetDriveType Lib "kernel32" Alias _
                                "GetDriveTypeA" (ByVal sDrive As String) As LongPtr
GetExitCodeProcess
#If VBA7 Then
    Declare PtrSafe Function GetExitCodeProcess Lib "kernel32" (ByVal _
        hProcess As LongPtr, lpExitCode As LongAs Long
#Else
    Declare Function GetExitCodeProcess Lib "kernel32" (ByVal _
        hProcess As Long, lpExitCode As LongAs Long
#End If
GetForegroundWindow
Declare Function GetForegroundWindow Lib "user32.dll" () As Long

Declare PtrSafe Function GetForegroundWindow Lib "user32.dll" () As LongPtr
getFrequency
Declare Function getFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (cyFrequency As CurrencyAsLong

Private
 Declare PtrSafe Function getFrequency Lib "kernel32" Alias "QueryPerformanceFrequency" (cyFrequency As CurrencyAs Long
GetKeyState
Declare Function GetKeyState Lib "USER32" (ByVal vKey As LongAs Integer

Declare
 PtrSafe Function GetKeyState Lib "USER32" (ByVal vKey As LongAs Integer
GetLastInputInfo
#If VBA7 Then
    Private Type LASTINPUTINFO
        cbSize As LongPtr
        dwTime As LongPtr
    End Type
    Private Declare PtrSafe Sub GetLastInputInfo Lib "USER32" (ByRef plii As LASTINPUTINFO)
#Else
    Private Type LASTINPUTINFO
        cbSize As Long
        dwTime As Long
    End Type
    Private Declare Sub GetLastInputInfo Lib "USER32" (ByRef plii As LASTINPUTINFO)
#End If
GetOpenFileName
Option Explicit

#If VBA7 Then
    Public Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias _
            "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
       
    Public Type OPENFILENAME
        lStructSize As Long
        hwndOwner As LongPtr
        hInstance As LongPtr
        lpstrFilter As String
        lpstrCustomFilter As String
        nMaxCustFilter As Long
        nFilterIndex As Long
        lpstrFile As String
        nMaxFile As Long
        lpstrFileTitle As String
        nMaxFileTitle As Long
        lpstrInitialDir As String
        lpstrTitle As String
        flags As Long
        nFileOffset As Integer
        nFileExtension As Integer
        lpstrDefExt As String
        lCustData As Long
        lpfnHook As LongPtr
        lpTemplateName As String
    End Type
   
#Else

    Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
            "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
       
    Public Type OPENFILENAME
        lStructSize As Long
        hwndOwner As Long
        hInstance As Long
        lpstrFilter As String
        lpstrCustomFilter As String
        nMaxCustFilter As Long
        nFilterIndex As Long
        lpstrFile As String
        nMaxFile As Long
        lpstrFileTitle As String
        nMaxFileTitle As Long
        lpstrInitialDir As String
        lpstrTitle As String
        flags As Long
        nFileOffset As Integer
        nFileExtension As Integer
        lpstrDefExt As String
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
    End Type
#End If
'/////////////////////////////////
'// End code GetOpenFileName    //
'/////////////////////////////////


Public Function GetMyFile(strTitle As StringAs String

    Dim OpenFile    As OPENFILENAME
    Dim lReturn     As Long
   
    OpenFile.lpstrFilter = ""
    OpenFile.nFilterIndex = 1
    OpenFile.hwndOwner = 0
    OpenFile.lpstrFile = String(257, 0)
    #If VBA7 Then
        OpenFile.nMaxFile = LenB(OpenFile.lpstrFile) - 1
        OpenFile.lStructSize = LenB(OpenFile)
    #Else
        OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
        OpenFile.lStructSize = Len(OpenFile)
    #End If
    OpenFile.lpstrFileTitle = OpenFile.lpstrFile
    OpenFile.nMaxFileTitle = OpenFile.nMaxFile
    OpenFile.lpstrInitialDir = "C:\"
    OpenFile.lpstrTitle = strTitle
    OpenFile.flags = 0
    lReturn = GetOpenFileName(OpenFile)
   
    If lReturn = 0 Then
        GetMyFile = ""
    Else
        GetMyFile = Trim(Left(OpenFile.lpstrFile, InStr(1, OpenFile.lpstrFile, vbNullChar) - 1))
    End If
   
End Function

GetSystemMetrics
Private Declare Function GetSystemMetrics Lib "USER32" (ByVal nIndex As LongAs Long

Private
 Declare PtrSafe Function GetSystemMetrics Lib "USER32" (ByVal nIndex As LongAs Long
GetTempPath
Declare Function GetTempPath Lib "kernel32" _
                             Alias "GetTempPathA" (ByVal nBufferLength As Long, _
                                                   ByVal lpbuffer As StringAs Long

Declare PtrSafe Function GetTempPath Lib "kernel32" _
                             Alias "GetTempPathA" (ByVal nBufferLength As longptr, _
                                                   ByVal lpbuffer As String) As Long
getTickCount
Private Declare Function getTickCount Lib "kernel32" Alias "QueryPerformanceCounter" (cyTickCount AsCurrencyAs Long

Private
 Declare PtrSafe Function getTickCount Lib "kernel32" Alias "QueryPerformanceCounter" (cyTickCount AsCurrencyAs Long
    '
getTime
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Private
 Declare PtrSafe Function timeGetTime Lib "winmm.dll" () As Long
GetWindow
Public Declare Function GetWindow Lib "USER32" _
                                  (ByVal hWnd As LongByVal wCmd As LongAs Long

Public Declare PtrSafe Function 
GetWindow Lib "USER32" _
                                  (ByVal hWnd As LongPtr, ByVal wCmd As Long) As LongPtr
GetWindowLongThis is one of the few API functions that requires the Win64 compile constant:
#If VBA7 Then
    #If Win64 Then
        Private Declare PtrSafe Function GetWindowLongPtr Lib "USER32" Alias "GetWindowLongPtrA" (ByVal hWnd As LongPtr, ByVal nIndex As LongAs LongPtr
    #Else
        Private Declare PtrSafe Function GetWindowLongPtr Lib "USER32" Alias "GetWindowLongA" (ByVal hWnd AsLongPtr, ByVal nIndex As LongAs LongPtr
    #End If
#Else
    Private Declare Function GetWindowLongPtr Lib "USER32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByValnIndex As LongAs Long 
#End If
GetWindowsDirectory
Declare Function GetWindowsDirectory& Lib "kernel32" Alias _
                                      "GetWindowsDirectoryA" (ByVal lpbuffer As String_
                                                              ByVal
 nSize As Long)

Declare PtrSafe Function GetWindowsDirectory& Lib "kernel32" Alias _
                                      "GetWindowsDirectoryA" (ByVal lpbuffer As String_
                                                              ByVal
 nSize As LongPtr)
GetWindowText
Public Declare Function GetWindowText Lib "USER32" Alias "GetWindowTextA" _
                                      (ByVal hWnd As LongByVal lpString As String, _
                                       ByVal cch As LongAs Long

Public Declare PtrSafe Function GetWindowText Lib "USER32" Alias "GetWindowTextA" _
                                      (ByVal hWnd As LongPtr, ByVal lpString As String, _
                                       ByVal cch As LongPtr) As Long
InternetGetConnectedState
Public Declare Function InternetGetConnectedState _
        Lib "wininet.dll" (lpdwFlags As Long, _
        ByVal dwReserved As LongAs Boolean

Public Declare PtrSafe Function InternetGetConnectedState _
        Lib "wininet.dll" (lpdwFlags As LongPtr, _
        ByVal dwReserved As long) As Boolean
IsCharAlphaNumericA
Private Declare Function IsCharAlphaNumericA Lib "USER32" (ByVal byChar As ByteAs Long

Private
 Declare PtrSafe Function IsCharAlphaNumericA Lib "USER32" (ByVal byChar As ByteAs Long
OleCreatePictureIndirect
Private Declare Function OleCreatePictureIndirect Lib "oleaut32.dll" (PicDesc As PICTDESC, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long

Private Type PICTDESC
    Size As Long
    Type As Long
    hPic As Long
    hPal As Long
End Type

Private Declare PtrSafe Function OleCreatePictureIndirect Lib "oleaut32.dll" (PicDesc As PICTDESC, RefIID As GUID, ByVal fPictureOwnsHandle As LongPtr, IPic As IPicture) As LongPtr

Private Type PICTDESC
    Size As Long
    Type As Long
    hPic As LongPtr
    hPal As LongPtr
End Type
OpenProcess
#If VBA7 Then
    Declare PtrSafe Function OpenProcess Lib "kernel32" (ByVal _
        dwDesiredAccess As LongByVal bInheritHandle As Long, ByVal _
        dwProcessId As LongAs LongPtr
#Else
    Declare Function OpenProcess Lib "kernel32" (ByVal _
        dwDesiredAccess As LongByVal bInheritHandle As Long, ByVal _
        dwProcessId As LongAs Long
#End If
ReleaseDC
Private Declare Function ReleaseDC Lib "USER32" (ByVal hWnd As LongByVal hDC As LongAs Long

Private
 Declare PtrSafe Function ReleaseDC Lib "USER32" (ByVal hWnd As LongPtrByVal hDC As LongPtr) As Long
SendMessage
Public Declare Function SendMessageA Lib "user32" (ByVal hWnd As LongByVal wMsg As Long, _
                                                   ByVal wParam As Long, lParam As Any) As Long
Public Declare PtrSafe Function SendMessageA Lib "user32" (ByVal hWnd As LongPtrByVal wMsg As Long, _
                                                           ByVal wParam As LongPtr, lParam As Any) As LongPtr
SetActiveWindow
Declare Function SetActiveWindow Lib "user32.dll" (ByVal hWnd As LongAs Long

Declare PtrSafe Function SetActiveWindow Lib "user32.dll" (ByVal hWnd As LongPtrAs LongPtr
SetCurrentDirectory
Private Declare Function SetCurrentDirectoryA Lib "kernel32" (ByVal lpPathName As StringAs Long

Private
 Declare PtrSafe Function SetCurrentDirectoryA Lib "kernel32" (ByVal lpPathName As StringAs Long
SetWindowLongPtrThis is one of the few API functions that requires the Win64 compile constant:
#If VBA7 Then
    #If Win64 Then
        Private Declare PtrSafe Function SetWindowLongPtr Lib "USER32" Alias "SetWindowLongPtrA" (ByVal hWnd As LongPtr, ByVal nIndex As LongByVal dwNewLong As LongPtrAs LongPtr
    #Else
        Private Declare Function SetWindowLongPtr Lib "USER32" Alias "SetWindowLongA" (ByVal hWnd AsLongPtr, ByVal nIndex As LongByVal dwNewLong As LongPtrAs LongPtr
    #End If
#Else
    Private Declare Function SetWindowLongPtr Lib "USER32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByValnIndex As LongByVal dwNewLong As LongAs Long 
#End If
SHBrowseForFolder
#If VBA7 Then
    Private Type BROWSEINFO
        hOwner As LongPtr
        pidlRoot As LongPtr
        pszDisplayName As String
        lpszTitle As String
        ulFlags As Long
        lpfn As LongPtr
        lParam As LongPtr
        iImage As Long
    End Type
                        
    Private Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" _
        (lpBrowseInfo As BROWSEINFO) As LongPtr
#Else
    Private Type BROWSEINFO
        hOwner As Long
        pidlRoot As Long
        pszDisplayName As String
        lpszTitle As String
        ulFlags As Long
        lpfn As Long
        lParam As Long
        iImage As Long
    End Type
                        
    Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" _
        (lpBrowseInfo As BROWSEINFO) As Long
#End If
Private Const BIF_RETURNONLYFSDIRS = &H1
ShellExecute
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
        ByVal hwnd As LongByVal lpOperation As StringByVal lpFile As String, _
        ByVal lpParameters As StringByVal lpDirectory As StringByVal nShowCmd As LongAs Long

Private
 Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
        ByVal hwnd As LongPtrByVal lpOperation As StringByVal lpFile As String, _
        ByVal lpParameters As StringByVal lpDirectory As StringByVal nShowCmd As LongAs LongPtr
SHFileOperation
#If VBA7 Then
    Type SHFILEOPSTRUCT
        hWnd As LongPtr
        wFunc As Long
        pFrom As String
        pTo As String
        fFlags As Integer
        fAborted As Boolean
        hNameMaps As Longptr
        sProgress As String
    End Type
    Declare PtrSafe Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
                                     (lpFileOp As SHFILEOPSTRUCT) As LongPtr
#Else
    Type SHFILEOPSTRUCT
        hWnd As Long
        wFunc As Long
        pFrom As String
        pTo As String
        fFlags As Integer
        fAborted As Boolean
        hNameMaps As Long
        sProgress As String
    End Type
    Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
                                     (lpFileOp As SHFILEOPSTRUCT) As Long
#End If
SHGetPathFromIDList
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
        (ByVal pidl As LongByVal pszPath As StringAs Boolean

Private Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
        (ByVal pidl As LongPtr, ByVal pszPath As String) As Boolean
SHGetSpecialFolderLocation
    Private Declare Function SHGetSpecialFolderLocation Lib _
        "shell32.dll" (ByVal hwndOwner As LongByVal nFolder As Long, _
        pidl As ITEMIDLIST) As Long

    Private Declare PtrSafe Function SHGetSpecialFolderLocation Lib _
        "shell32.dll" (ByVal hwndOwner As LongPtr, ByVal nFolder As Long, _
        pidl As ITEMIDLIST) As LongPtr

    Private Type SHITEMID
        cb As Long
        abID As Byte
     End Type
     Private Type ITEMIDLIST
        mkid As SHITEMID
     End Type
timeGetTime
Private Declare Function timeGetTime Lib "winmm.dll" () As Long

Private
 Declare PtrSafe Function timeGetTime Lib "winmm.dll" () As Long





문서 첨부 제한 : 0Byte/ 2.00MB
파일 제한 크기 : 2.00MB (허용 확장자 : *.*)
List of Articles
번호 제목 글쓴이 날짜 조회 수sort
공지 기타 엑셀 VBA 간단한 팁 모아놓기.. +_+ [레벨:30]아별 2007-01-24 33819
64 기타 오피스2010 64bit(64비트)를 위한 API Declare 방법 _ 윈도우 도움말 file [레벨:30]아별 2017-04-21 39350
63 [펌] Visual Basic (비쥬얼 베이직) 함수 정리 imagefile [레벨:30]아별 2009-11-27 20068
62 시트에서 콤보박스 활용하기 file [레벨:30]a☆ 2005-11-12 16708
61 메시지 박스 대용으로 Shape 사용하기 file [레벨:30]아별 2009-05-07 16045
60 기타 [펌] 엑셀 VBA 총정리 _ Excel 개체 모델 참조 등 image [2] [레벨:30]아별 2010-03-09 15919
59 [VBA] 전역변수 설정하기. Public 문, Private 문 imagefile [레벨:30]아별 2008-07-01 14019
58 엑셀에서 사용하는 언어 확인하기. file [1] [레벨:30]아별 2009-06-03 13776
57 기타 [펌] VBA 공부를 시작하시는분들에게 추천하는 강의자료 imagefile [4] [레벨:30]아별 2011-03-21 13698
56 기타 [Excel VBA] 피벗테이블(PivotTable)을 VBA로 컨트롤해보자.. [레벨:30]아별 2008-12-19 12076
55 [엑셀VBA] 자동필터를 매크로로 구현하기 [레벨:30]아별 2008-08-28 11224
54 엑셀에서 달력 집어 넣기.. [1] [레벨:30]a☆ 2004-10-21 10947
53 엑셀2007에서 셀의 색상을 RGB로 뽑아내기 file [레벨:30]아별 2009-10-06 10197
52 엑셀의 유저폼 관련 [1] [레벨:30]a☆ 2004-10-21 10049
51 엑셀에서 줄바꿈에 대해서.. 줄바꿈하기 제거하기 등등.. [레벨:30]a☆ 2004-11-15 9992
50 기타 [링크] VBA로 파일을 다루는 방법에 대한 강좌들을 모아놓은 겁니다. [레벨:30]아별 2010-03-03 9832
» 기타 오피스2010 64bit(64비트)를 위한 API Declare 방법 file [2] [레벨:30]아별 2011-10-05 9218
48 [엑셀VBA] 네이버 지식인 답변 _ 엑셀 쿼리를 이용해서 펀드 기준가 데이터를 읽어오기. file [레벨:30]아별 2008-04-30 9120
47 기타 VBA _ 레지스트리 다루기 ( registry control ) imagefile [레벨:30]아별 2011-03-19 8672
46 [10/19일 수정] 엑셀 매크로 수정하기... [2] [레벨:30]a☆ 2003-09-29 8250