GdipSaveImageToFile使用求解,希望能将剪贴板的内容另存为图片D:\test.jpg
GdipSaveImageToFile使用求解,希望能将剪贴板的内容另存为图片D:\test.jpg
感谢sych的帮助,前面他发了代码,win10+VFP9环境测试成功
DECLARE INTEGER GetClipboardData IN win32api INTEGER
DECLARE INTEGER OpenClipboard IN win32api INTEGER
DECLARE INTEGER CloseClipboard IN win32api
DECLARE LONG IsClipboardFormatAvailable IN user32 LONG
DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
Declare Long GdiplusShutdown in GdiPlus Long token
Declare Long GdiplusStartup in GdiPlus Long @ token, String @ input, Long @ output
DECLARE INTEGER GdipCreateBitmapFromHBITMAP in GdiPlus.dll INTEGER, INTEGER, INTEGER @
DECLARE INTEGER GdipSaveImageToFile in GdiPlus.dll INTEGER,String,String @,String @
DECLARE LONG GdipDisposeImage IN GDIPLUS LONG nImage
IF IsClipboardFormatAvailable(2)=0
MESSAGEBOX("剪贴板中没有图像",64,"温馨提示")
else
IF OpenClipboard(0)=0
MESSAGEBOX("剪贴板打开失败",64,"温馨提示")
else
lcOutputFile="D:\test.jpg"
hBitmap = GetClipboardData(2) &&CF_BITMAP=2
hToken=0
cInput = PADR(CHR(1), 16, CHR(0))
GdiplusStartup(@hToken, @cInput, 0)
ubitmap=0
GdipCreateBitmapFromHBITMAP(hBitmap,2,@ubitmap)
qEncoderClsID_BMP=0h00F47C55041AD3119A730000F81EF32E
GdipSaveImageToFile(ubitmap,STRCONV(lcOutputFile+CHR(0),5),qEncoderClsID_BMP,null)
GdipDisposeImage(ubitmap)
GdiplusShutdown(m.hToken)
closehandle(hBitmap)
CloseClipboard()
endif
endif