C++:
#include <windows.h>
#include <olectl.h>
LPDISPATCH pImage;
void __stdcall isJpgtoBmp(LPCTSTR pszFileName,char *outName)
{
HANDLE hFile=CreateFile(pszFileName,GENERIC_READ,0,NULL,
OPEN_EXISTING,0,NULL);
DWORD dwFileSize=GetFileSize(hFile,NULL);
HGLOBAL hGlobalA=GlobalAlloc(GMEM_MOVEABLE,dwFileSize);
LPVOID pvData=GlobalLock(hGlobalA);
DWORD dwBytesRead=0;
BOOL bReadFile=ReadFile(hFile,pvData,dwFileSize,&dwBytesRead,NULL);
GlobalUnlock(hGlobalA);
CloseHandle(hFile);
LPSTREAM pst=NULL;
HRESULT hr=CreateStreamOnHGlobal(hGlobalA,TRUE,&pst);
if(pImage) pImage->Release();
hr=OleLoadPicture(pst,dwFileSize,FALSE,IID_IPicture,(LPVOID*)&pImage);
pst->Release();
WCHAR fBuff[MAX_PATH];
mbstowcs(fBuff,outName,sizeof(fBuff)/sizeof(WCHAR));
OleSavePictureFile(pImage,fBuff);
}
Код:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=.
[Files]
Source: "1.jpg"; DestDir: "{tmp}"; Flags: dontcopy ignoreversion nocompression;
Source: "MyDll.dll"; DestDir: "{tmp}"; Flags: dontcopy ignoreversion nocompression;
[Code]
procedure isJpgtoBmp(filename: PansiChar; name: AnsiString);
external 'isJpgtoBmp@files:MyDll.dll stdcall delayload';
function InitializeSetup(): Boolean;
begin
if not FileExists(ExpandConstant('{tmp}\MyDll.dll')) then ExtractTemporaryFile('MyDll.dll');
if not FileExists(ExpandConstant('{tmp}\1.jpg')) then ExtractTemporaryFile('1.jpg');
Result:= True;
end;
function NextButtonClick(CurPage: Integer): Boolean;
begin
if CurPage = wpWelcome then begin
isJpgtoBmp(PChar(ExpandConstant('{tmp}\1.jpg')),'1');
end;
Result := True;
end;
Вложения
-
1.3 MB Просмотры: 19