' 暫定措置

#require <api_winerror.sbp>

#require <objbase.sbp>
#require <oleauto.ab>
#ifdef __UNDEFINED '#165が解決するまでの暫定
' View OBJECT Error Codes

Const E_DRAW = VIEW_E_DRAW

' IDataObject Error Codes
Const DATA_E_FORMATETC = DV_E_FORMATETC

' Common stuff gleamed from OLE.2,

/* verbs */
Const OLEIVERB_PRIMARY           = (0)
Const OLEIVERB_SHOW              = (-1)
Const OLEIVERB_OPEN              = (-2)
Const OLEIVERB_HIDE              = (-3)
Const OLEIVERB_UIACTIVATE        = (-4)
Const OLEIVERB_INPLACEACTIVATE   = (-5)
Const OLEIVERB_DISCARDUNDOSTATE  = (-6)

' for OleCreateEmbeddingHelper flags; roles in low word; options in high word
Const EMBDHLP_INPROC_HANDLER  = &h0000
Const EMBDHLP_INPROC_SERVER   = &h0001
Const EMBDHLP_CREATENOW   = &h00000000
Const EMBDHLP_DELAYCREATE = &h00010000

/* extended create function flags */
Const OLECREATE_LEAVERUNNING = &h00000001

/* pull in the MIDL generated header */

#require <oleidl.ab>

/****** DV APIs ***********************************************************/

/*
#if    !defined(ISOLATION_AWARE_ENABLED) \
    || !ISOLATION_AWARE_ENABLED \
    || !defined(_OBJBASE_H_) \
    || !defined(CreateDataAdviseHolder)
WINOLEAPI CreateDataAdviseHolder(OUT LPDATAADVISEHOLDER FAR* ppDAHolder);
#endif
*/

/****** OLE API Prototypes ************************************************/

Declare Function OleBuildVersion Lib "ole32.dll" () As DWord

/* helper functions */
Declare Function ReadClassStg Lib "ole32.dll" (/*IN*/ ByVal stg As IStorage, /*OUT*/ ByRef clsid As CLSID) As HRESULT
Declare Function WriteClassStg Lib "ole32.dll" (/*IN*/ ByVal stg As IStorage, /*IN*/ ByRef clsid As CLSID) As HRESULT
Declare Function ReadClassStm Lib "ole32.dll" (/*IN*/ ByVal stm As IStream, /*OUT*/ ByRef clsid As CLSID) As HRESULT
Declare Function WriteClassStm Lib "ole32.dll" (/*IN*/ ByVal stm As IStream, /*IN*/ ByRef clsid As CLSID) As HRESULT
Declare Function WriteFmtUserTypeStg Lib "ole32.dll" (/*IN*/ ByVal stg As IStorage, /*IN*/ ByVal cf As CLIPFORMAT, /*IN*/ ByVal pszUserType As *OLECHAR) As HRESULT
Declare Function ReadFmtUserTypeStg Lib "ole32.dll" (/*IN*/ ByVal stg As IStorage, /*OUT*/ ByRef cf As CLIPFORMAT, /*OUT*/ ByRef rpszUserType As *OLECHAR) As HRESULT


/* init/term */

Declare Function OleInitialize Lib "ole32" (pvReserved As VoidPtr) As HRESULT
Declare Sub OleUninitialize Lib "ole32" ()


/* APIs to query whether (Embedded/Linked) object can be created from
   the data object */

Declare Function OleQueryLinkFromData Lib "ole32" (/*IN*/ ByVal srcDataObject As IDataObject) As HRESULT
Declare Function OleQueryCreateFromData Lib "ole32.dll" (/*IN*/ ByVal srcDataObject As IDataObject) As HRESULT


/* Object creation APIs */

Declare Function OleCreate Lib "ole32.dll" (/*IN*/ ByRef rclsid As CLSID, /*IN*/ ByRef riid As IID, /*IN*/ ByVal renderopt As DWord,
	/*IN*/ ByVal pFormatEtc As *FORMATETC, /*IN*/ ByVal clientSite As IOleClientSite,
	/*IN*/ ByVal stg As IStorage, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateEx Lib "ole32.dll" (/*IN*/ ByRef rclsid As CLSID, /*IN*/ ByRef riid As IID, /*IN*/ ByVal dwFlags As DWord,
	/*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal cFormats As DWord, /*IN*/ ByVal rgAdvf As *DWord,
	/*IN*/ ByVal rgFormatEtc As *FORMATETC, /*IN*/ ByVal adviseSink As IAdviseSink,
	/*OUT*/ ByVal rgdwConnection As *DWord, /*IN*/ ByVal clientSite As IOleClientSite,
	/*IN*/ ByVal stg As IStorage, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateFromData Lib "ole32.dll" (/*IN*/ ByVal srcDataObj As IDataObject, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal pFormatEtc As *FORMATETC,
	/*IN*/ ByVal clientSite As IOleClientSite, /*IN*/ ByVal stg As IStorage,
	/*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateFromDataEx Lib "ole32.dll" (/*IN*/ ByVal srcDataObj As IDataObject, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal dwFlags As DWord, /*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal cFormats As DWord, /*IN*/ ByVal rgAdvf As *DWord,
	/*IN*/ ByVal rgFormatEtc As *FORMATETC, /*IN*/ ByVal adviseSink As IAdviseSink,
	/*OUT*/ ByVal rgdwConnection As *DWord, /*IN*/ ByVal clientSite As IOleClientSite,
	/*IN*/ ByVal stg As IStorage, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateLinkFromData Lib "ole32.dll" (/*IN*/ ByVal srcDataObj As IDataObject, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal pFormatEtc As *FORMATETC,
	/*IN*/ ByVal clientSite As IOleClientSite, /*IN*/ ByVal stg As IStorage,
	/*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateLinkFromDataEx Lib "ole32.dll" (/*IN*/ ByVal srcDataObj As IDataObject, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal dwFlags As DWord, /*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal cFormats As DWord, /*IN*/ ByVal rgAdvf As *DWord,
	/*IN*/ ByVal rgFormatEtc As *FORMATETC, /*IN*/ ByVal adviseSink As IAdviseSink,
	/*OUT IN*/ ByVal rgdwConnection As *DWord, /*IN*/ ByVal clientSite As IOleClientSite,
	/*IN*/ ByVal stg As IStorage, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateStaticFromData Lib "ole32.dll" (/*IN*/ ByVal srcDataObj As IDataObject, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal pFormatEtc As *FORMATETC,
	/*IN*/ ByVal clientSite As IOleClientSite, /*IN*/ ByVal stg As IStorage,
	/*OUT*/ ByRef ppvObj As Any) As HRESULT


Declare Function OleCreateLink Lib "ole32.dll" (/*IN*/ ByVal mkLinkSrc As IMoniker, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal pFormatEtc As *FORMATETC,
	/*IN*/ ByVal clientSite As IOleClientSite, /*IN*/ ByVal dataObj As IDataObject, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateLinkEx Lib "ole32.dll" (/*IN*/ ByVal mkLinkSrc As IMoniker, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal dwFlags As DWord, /*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal cFormats As DWord, /*IN*/ ByVal rgAdvf As *DWord,
	/*IN*/ ByVal rgFormatEtc As *FORMATETC, /*IN*/ ByVal adviseSink As IAdviseSink,
	/*OUT*/ ByVal rgdwConnection As *DWord, /*IN*/ ByVal clientSite As IOleClientSite,
	/*IN*/ ByVal dataObj As IDataObject, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateLinkToFile Lib "ole32.dll" (/*IN*/ ByVal lpszFileName As LPCOLESTR, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal pFormatEtc As *FORMATETC,
	/*IN*/ ByVal clientSite As IOleClientSite, /*IN*/ ByValdataObj As IDataObject, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateLinkToFileEx Lib "ole32.dll" (/*IN*/ ByVal lpszFileName As LPCOLESTR, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal dwFlags As DWord, /*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal cFormats As DWord, /*IN*/ ByVal rgAdvf As *DWord,
	/*IN*/ ByVal rgFormatEtc As *FORMATETC, /*IN*/ ByVal adviseSink As IAdviseSink,
	/*OUT*/ ByVal rgdwConnection As *DWord, /*IN*/ ByVal clientSite As IOleClientSite,
	/*IN*/ ByVal dataObj As IDataObject, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateFromFile Lib "ole32.dll" (/*IN*/ ByRef rclsid As CLSID, /*IN*/ ByVal lpszFileName As LPOLESTR, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal pFormatEtc As *FORMATETC,
	/*IN*/ ByVal clientSite As IOleClientSite, /*IN*/ ByVal dataObj As IDataObject, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleCreateFromFileEx Lib "ole32.dll" (/*IN*/ ByRef rclsid As CLSID, /*IN*/ ByVal lpszFileName As LPOLESTR, /*IN*/ ByRef riid As IID,
	/*IN*/ ByVal dwFlags As DWord, /*IN*/ ByVal renderopt As DWord, /*IN*/ ByVal cFormats As DWord, /*IN*/ ByVal rgAdvf As *DWord,
	/*IN*/ ByVal rgFormatEtc As *FORMATETC, /*IN*/ ByVal adviseSink As IAdviseSink,
	/*OUT*/ ByVal rgdwConnection As *DWord, /*IN*/ ByVal clientSite As IOleClientSite,
	/*IN*/ ByVal dataObj As IDataObject, /*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleLoad Lib "ole32.dll" (/*IN*/ ByVal stg As IStorage, /*IN*/ ByRef riid As IID, /*IN*/ ByVal clientSite As IOleClientSite,
	/*OUT*/ ByRef ppvObj As Any) As HRESULT

Declare Function OleSave Lib "ole32.dll" (/*IN*/ ByVal ps As IPersistStorage, /*IN*/ ByVal stg As IStorage, /*IN*/ fSameAsLoad As BOOL) As HRESULT

Declare Function OleLoadFromStream Lib "ole32.dll" ( /*IN*/ ByVal stm As IStream, /*IN*/ ByRef iidInterface As IID, /*OUT*/ ByRef ppvObj As Any) As HRESULT
Declare Function OleSaveToStream Lib "ole32.dll" ( /*IN*/ ByVal pstm As IPersistStream, /*IN*/ ByVal stm As IStream) As HRESULT


Declare Function OleSetContainedObject Lib "ole32.dll" (/*IN*/ ByVal unknown As IUnknown, /*IN*/ ByVal fContained As BOOL) As HRESULT
Declare Function OleNoteObjectVisible Lib "ole32.dll" (/*IN*/ ByVal unknown As IUnknown, /*IN*/ ByVal fContained As BOOL) As HRESULT


/* Drag/Drop APIs */

Declare Function RegisterDragDrop Lib "ole32.dll" (/*IN*/ ByVal hwnd As HWND, /*IN*/ ByVal dropTarget As IDropTarget) As HRESULT
Declare Function RevokeDragDrop Lib "ole32.dll" (/*IN*/ ByVal hwnd As HWND) As HRESULT
Declare Function DoDragDrop Lib "ole32.dll" (/*IN*/ ByVal dataObj As IDataObject, /*IN*/ ByVal dropSource As IDropSource,
	/*IN*/ ByVal dwOKEffects As DWord, /*OUT*/ ByRef dwEffect As DWord) As HRESULT

/* Clipboard APIs */

Declare Function OleSetClipboard Lib "ole32.dll" (/*IN*/ ByVal dataObj As IDataObject) As HRESULT
Declare Function OleGetClipboard Lib "ole32.dll" (/*OUT*/ ByRef dataObj As IDataObject) As HRESULT
Declare Function OleFlushClipboard Lib "ole32.dll" () As HRESULT
Declare Function OleIsCurrentClipboard Lib "ole32.dll" (/*IN*/ ByVal dataObj As IDataObject) As HRESULT


/* InPlace Editing APIs */

TypeDef HOLEMENU = HGLOBAL ' oleidl.h
Type OLEMENUGROUPWIDTHS ' oleidl.h
	width[ELM(6)] As Long
End Type
Type OLEINPLACEFRAMEINFO ' oleidl.h
	cb As DWord
	fMDIApp As BOOL
	hwndFrame As HWND
	haccel As HACCEL
	cAccelEntries As DWord
End Type
Declare Function OleCreateMenuDescriptor Lib "ole32.dll" (/*IN*/ ByVal hmenuCombined As HMENU,
	/*IN*/ ByRef MenuWidths As OLEMENUGROUPWIDTHS) As HOLEMENU
Declare Function OleSetMenuDescriptor Lib "ole32.dll" (/*IN*/ ByVal holemenu As HOLEMENU, /*IN*/ ByVal hwndFrame As HWND,
	/*IN*/ ByVal hwndActiveObject As HWND,
	/*IN*/ ByVal frame As IOleInPlaceFrame,
	/*IN*/ ByVal activeObj As IOleInPlaceActiveObject) As HRESULT
Declare Function OleDestroyMenuDescriptor Lib "ole32.dll" (/*IN*/ ByVal holemenu As HOLEMENU) As HRESULT

Declare Function OleTranslateAccelerator Lib "ole32.dll" (/*IN*/ ByVal frame As IOleInPlaceFrame,
	/*IN*/ ByRef FrameInfo As OLEINPLACEFRAMEINFO, /*IN*/ ByRef msg As MSG) As HRESULT


/* Helper APIs */
Declare Function OleDuplicateData Lib "ole32.dll" (/*IN*/ ByVal hSrc As HANDLE, /*IN*/ ByVal cfFormat As CLIPFORMAT,
	/*IN*/ ByVal uiFlags As DWord) As HANDLE

Declare Function OleDraw Lib "ole32.dll" (/*IN*/ ByVal unknown As IUnknown, /*IN*/ ByVal dwAspect As DWord, /*IN*/ ByVal hdcDraw As HDC,
	/*IN*/ ByRef rcBounds As RECT) As HRESULT

Declare Function OleRun Lib "ole32.dll" (/*IN*/ ByVal unknown As IUnknown) As HRESULT
Declare Function OleIsRunning Lib "ole32.dll" (/*IN*/ ByVal object As IOleObject) As BOOL
Declare Function OleLockRunning Lib "ole32.dll" (/*IN*/ ByVal unknown As IUnknown, /*IN*/ ByVal fLock As BOOL, /*IN*/ ByVal fLastUnlockCloses As BOOL) As HRESULT
Declare Sub      ReleaseStgMedium Lib "ole32.dll" (/*IN*/ ByRef medium As STGMEDIUM)
Declare Function CreateOleAdviseHolder Lib "ole32.dll" (/*OUT*/ ByRef oaHolder As IOleAdviseHolder) As HRESULT

Declare Function OleCreateDefaultHandler Lib "ole32.dll" (/*IN*/ ByRef clsid As CLSID, /*IN*/ ByVal unkOuter As IUnknown,
	/*IN*/ ByRef riid As IID, /*OUT*/ ByRef pObj As Any) As HRESULT

Declare Function OleCreateEmbeddingHelper Lib "ole32.dll" (/*IN*/ ByRef clsid As CLSID, /*IN*/ ByVal ukOuter As IUnknown,
	/*IN*/ ByVal flags As DWord, /*IN*/ ByVal cf As IClassFactory,
	/*IN*/ ByRef riid As IID, /*OUT*/ ByRef pObj As Any) As HRESULT

Declare Function IsAccelerator Lib "ole32.dll" (/*IN*/ ByVal hAccel As HACCEL, /*IN*/ ByVal cAccelEntries As Long, /*IN*/ ByRef msg As MSG,
	/*OUT*/ ByVal pwCmd As *Word) As BOOL
/* Icon extraction Helper APIs */

Declare Function OleGetIconOfFile Lib "ole32.dll" (/*IN*/ ByVal lpszPath As LPOLESTR, /*IN*/ ByVal fUseFileAsLabel As BOOL) As HGLOBAL

Declare Function OleGetIconOfClass Lib "ole32.dll" (/*IN*/ ByRef rclsid As CLSID, /*IN*/ ByVal lpszLabel As LPOLESTR,
	/*IN*/ ByVal fUseTypeAsLabel As BOOL) As HGLOBAL

Declare Function OleMetafilePictFromIconAndLabel Lib "ole32.dll" (/*IN*/ ByVal hIcon As HICON, /*IN*/ ByVal lpszLabel As LPOLESTR,
	/*IN*/ ByVal lpszSourceFile As LPOLESTR, /*IN*/ ByVal iIconIndex As DWord) As HGLOBAL



/* Registration Database Helper APIs */

Declare Function OleRegGetUserType Lib "ole32.dll" (/*IN*/ ByRef rclsid As CLSID, /*IN*/ ByVal dwFormOfType As DWord,
	/*OUT*/ ByVal pszUserType As LPOLESTR) As HRESULT

Declare Function OleRegGetMiscStatus Lib "ole32.dll" (/*IN*/ ByRef rclsid As CLSID, /*IN*/ ByVal dwAspect As DWord,
	/*OUT*/ ByRef dwStatus As DWord) As HRESULT

Declare Function OleRegEnumFormatEtc Lib "ole32.dll" (/*IN*/ ByRef rclsid As CLSID, /*IN*/ ByVal dwDirection As DWord,
	/*OUT*/ ByRef penum As *IEnumFORMATETC) As HRESULT

Declare Function OleRegEnumVerbs Lib "ole32.dll" (/*IN*/ ByRef rclsid As CLSID, /*OUT*/ ByRef penum As *IEnumOLEVERB) As HRESULT

/* OLE 1.0 conversion APIS */

/***** OLE 1.0 OLESTREAM declarations *************************************/


Interface OleStream
	Function Get(p As VoidPtr, dw As DWord) As DWord
	Function Put(p As VoidPtr, dw As DWord) As DWord
End Interface
TypeDef LPOLESTREAM = *OleStream


Declare Function OleConvertOLESTREAMToIStorage Lib "ole32.dll" (
	/*IN*/ ByVal lpolestream As LPOLESTREAM,
	/*OUT*/ ByVal stg As IStorage,
	/*IN*/ ByRef td As DVTARGETDEVICE) As HRESULT

Declare Function OleConvertIStorageToOLESTREAM Lib "ole32.dll" (
	/*IN*/ ByVal stg As IStorage,
	/*OUT*/ ByVal lpolestream As LPOLESTREAM) As HRESULT


/* Storage Utility APIs */
Declare Function GetHGlobalFromILockBytes Lib "ole32.dll" (/*IN*/ ByVal plkbyt As *ILockBytes, /*OUT*/ ByRef hglobal As HGLOBAL) As HRESULT
Declare Function CreateILockBytesOnHGlobal Lib "ole32.dll" (/*IN*/ ByVal hGlobal As HGLOBAL, /*IN*/ ByVal fDeleteOnRelease As BOOL,
	/*OUT*/ ByRef lkbyt As ILockBytes) As HRESULT

Declare Function GetHGlobalFromStream Lib "ole32.dll" (/*IN*/ ByVal pstm As *IStream, /*OUT*/ ByRef hglobal As HGLOBAL) As HRESULT
Declare Function CreateStreamOnHGlobal Lib "ole32.dll" (/*IN*/ ByVal hGlobal As HGLOBAL, /*IN*/ ByVal fDeleteOnRelease As BOOL,
	/*OUT*/ ByRef stm As IStream) As HRESULT


/* ConvertTo APIS */

Declare Function OleDoAutoConvert Lib "ole32.dll" (/*IN*/ ByRef stg As IStorage, /*OUT*/ ByRef ClsidNew As CLSID) As HRESULT
Declare Function OleGetAutoConvert Lib "ole32.dll" (/*IN*/ ByRef clsidOld As CLSID, /*OUT*/ ByRef ClsidNew As CLSID) As HRESULT
Declare Function OleSetAutoConvert Lib "ole32.dll" (/*IN*/ ByRef clsidOld As CLSID, /*IN*/ ByRef ClsidNew As CLSID) As HRESULT
Declare Function GetConvertStg Lib "ole32.dll" (/*IN*/ ByVal stg As IStorage) As HRESULT
Declare Function SetConvertStg Lib "ole32.dll" (/*IN*/ ByVal stg As IStorage, /*IN*/ fConvert As BOOL) As HRESULT


Declare Function OleConvertIStorageToOLESTREAMEx Lib "ole32.dll" ( _
	/*IN*/ ByVal stg As IStorage,       ' Presentation data to OLESTREAM
	/*IN*/ ByVal cfFormat As CLIPFORMAT,  '       format
	/*IN*/ ByVal lWidth As Long,          '       width
	/*IN*/ ByVal lHeight As Long,         '       height
	/*IN*/ ByVal dwSize As DWORD,         '       size in bytes
	/*IN*/ ByRef medium As STGMEDIUM,     '       bits
	/*OUT*/ ByVal polestm As LPOLESTREAM) As HRESULT

Declare Function OleConvertOLESTREAMToIStorageEx Lib "ole32.dll" ( _
	/*IN*/ ByVal polestm As LPOLESTREAM,
	/*OUT*/ ByVal pstg As *IStorage,' Presentation data from OLESTREAM
	/*OUT*/ ByRef pcfFormat As CLIPFORMAT, '       format
	/*OUT*/ ByRef plwWidth As Long,        '       width
	/*OUT*/ ByRef plHeight As Long,        '       height
	/*OUT*/ ByRef pdwSize As DWord,        '       size in bytes
	/*OUT*/ ByRef medium As STGMEDIUM) As HRESULT   '      bits

' olectl.h
Declare Function OleLoadPicture Lib "olepro32" (stream As IStream, lSize As Long, fRunmode As BOOL, ByRef riid As IID, ppvObj As VoidPtr) As HRESULT
#endif '__UNDEFINED
