Microsoft KB Archive/268770

= PRB: LoadPicture and SavePicture Entry Points Are Not Found =

Article ID: 268770

Article Last Modified on 9/8/2003

-

APPLIES TO


 * Microsoft COM+ 2.0 Standard Edition

-



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(&quot;Loads a picture from a file&quot;), 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(&quot;Saves a picture to a file&quot;), 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 &quot;the specified procedure could not be found&quot; error in both cases: HMODULE hInst = LoadLibrary(&quot;oleaut32.dll&quot;); pnfLoadPicture = GetProcAddress(hInst, &quot;LoadPicture&quot;); 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(&quot;Functions for Standard OLE Objects&quot;), helpcontext(10101), dllname(&quot;oleaut32.dll&quot;)] module StdFunctions { [entry(&quot;OleLoadPictureFileEx&quot;), helpstring(&quot;Loads a picture from a file&quot;), 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(&quot;OleSavePictureFile&quot;), helpstring(&quot;Saves a picture to a file&quot;), helpcontext(10101)] HRESULT SavePicture(                        [in] IPictureDisp * Picture,                         [in] BSTR filename); } Therefore, a bug in Oleview.exe causes this problem.



RESOLUTION
According to the ODL source, the following code will correctly get the LoadPicture and the SavePicture entry points: HMODULE hInst = LoadLibrary(&quot;oleaut32.dll&quot;); pnfLoadPicture = GetProcAddress(hInst, &quot;OleLoadPictureFileEx&quot;); pnfSavePicture = GetProcAddress(hInst, &quot;OleSavePictureFile&quot;); 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.

