win10删除启动引导:VBA 一个能够获取图像大小(如800*600)的api函数

来源:百度文库 编辑:中财网 时间:2024/05/03 06:38:20
一个能够获取图像大小(如800*600)的api函数Private Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long    Private Type BITMAP    bmType   As Long    bmWidth   As Long    bmHeight   As Long    bmWidthBytes   As Long    bmPlanes   As Integer    bmBitsPixel   As Integer    bmBits   As LongEnd Type
Public Sub psize()
    Dim bm As BITMAP    Dim picPicture As IPictureDisp
    Set picPicture = stdole.LoadPicture("e:\gta.bmp")    
    Call GetObjectAPI(picPicture, Len(bm), bm)    MsgBox "大小  :  " & bm.bmWidth & "×" & bm.bmHeight
End Sub

'*********************************************************************************Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _  ByVal hdc As Long) As LongPrivate Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _  ByVal nIndex As Long) As Long
Sub getpicsize(ByVal picpath As String)Dim Image1 As OLEObject, d As LongApplication.ScreenUpdating = Falsed = GetDC(0)Set Image1 = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Image.1")Image1.Object.AutoSize = TrueImage1.Object.BorderStyle = 0Image1.Object.Picture = LoadPicture(picpath)MsgBox Image1.Width * GetDeviceCaps(d, 88) / 72 & "*" & Image1.Height * GetDeviceCaps(d, 90) / 72ReleaseDC 0, dImage1.DeleteApplication.ScreenUpdating = TrueEnd Sub

Sub Macro1()getpicsize "e:\001.gif"End Sub