PRB: LoadPicture and SavePicture Entry Points Are Not Found (268770)
The information in this article applies to:
This article was previously published under Q268770 SYMPTOMS When the OLE/COM Object Viewer (Oleview.exe) is used to
display contents of the StdFunctions module in Stdole2.tlb, it shows the following code:
module StdFunctions {
[entry(0x60000000), helpstring("Loads a picture from a file"), helpcontext(0x00002775)]
HRESULT _stdcall LoadPicture(
[in, optional] VARIANT filename,
[in, optional, defaultvalue(0)] int widthDesired,
[in, optional, defaultvalue(0)] int heightDesired,
[in, optional, defaultvalue(0)] LoadPictureConstants flags,
[out, retval] IPictureDisp** retval);
[entry(0x60000001), helpstring("Saves a picture to a file"), helpcontext(0x00002775)]
HRESULT _stdcall SavePicture(
[in] IPictureDisp* Picture,
[in] BSTR filename);
}; However, if the following code tries to access the LoadPicture entry point by using the HMODULE of Oleaut32.dll and either the name or the ordinal, it fails with "the specified procedure could not be found" error in both cases:
HMODULE hInst = LoadLibrary("oleaut32.dll");
pnfLoadPicture = GetProcAddress(hInst, "LoadPicture");
pnfLoadPicture = GetProcAddress(hInst, MAKEINTRESOURCE(0x60000000));
You experience similar behavior for the SavePicture entry point. CAUSE Actually, the LoadPicture and the SavePicture entry points are defined in Oleaut32.dll and they are
successfully used by Microsoft Visual Basic 6 when a Visual Basic 6 application
calls them. But Oleview.exe produces incorrect decompiled Interface Definition
Language (IDL) code from StdOle2.tlb. The actual Object Description Language
(ODL) source of StdOle2.tlb contains the string names, not the numeric IDs, of
the entry points:
[uuid(91209AC0-60F6-11cf-9C5D-00AA00C1489E), helpstring("Functions for Standard OLE Objects"), helpcontext(10101), dllname("oleaut32.dll")]
module StdFunctions {
[entry("OleLoadPictureFileEx"), helpstring("Loads a picture from a file"), helpcontext(10101)]
HRESULT LoadPicture(
[in, optional] VARIANT filename,
[in, defaultvalue(0)] int widthDesired,
[in, defaultvalue(0)] int heightDesired,
[in, defaultvalue(0)] LoadPictureConstants flags,
[out, retval] IPictureDisp * * retval);
[entry("OleSavePictureFile"), helpstring("Saves a picture to a file"), helpcontext(10101)]
HRESULT SavePicture(
[in] IPictureDisp * Picture,
[in] BSTR filename);
} Therefore, a bug in Oleview.exe causes this problem. RESOLUTIONAccording to the ODL source, the following code will
correctly get the LoadPicture and the SavePicture entry points:
HMODULE hInst = LoadLibrary("oleaut32.dll");
pnfLoadPicture = GetProcAddress(hInst, "OleLoadPictureFileEx");
pnfSavePicture = GetProcAddress(hInst, "OleSavePictureFile"); To instantiate the IPicture interface, you can also use the OleLoadPicture and OleCreatePictureIndirect functions. The properties and methods of IPicture can be used to manage the picture objects. REFERENCESFor additional information,
click the article number below to view the article in the Microsoft Knowledge
Base: 218972 How To Load and Display Graphics Files w/LOADPIC.EXE
Modification Type: | Major | Last Reviewed: | 9/8/2003 |
---|
Keywords: | kbprb KB268770 kbAudDeveloper |
---|
|