home *** CD-ROM | disk | FTP | other *** search
Java Source | 1999-03-17 | 11.2 KB | 324 lines |
- // (C) Copyright 1995 - 1999 Microsoft Corporation. All rights reserved.
-
- // These classes provide direct, low-overhead access to commonly used
- // Windows api. These classes use the new J/Direct feature.
- //
- // Information on how to use J/Direct to write your own declarations
- // can be found in the Microsoft SDK for Java.
- //
- // Methods marked as "ole" mode throw an instance of ComFailException
- // if the native method returns an unsuccessful HRESULT.
-
- package com.ms.win32;
-
- import com.ms.com.*;
-
-
- /** @security(checkClassLinking=on) */
- public class Ole32
- {
- /****** COM init/uninit methods *******************************************/
-
- /**
- * note that this method returns an HRESULT, the return value from the
- * system call.
- *
- * @dll.import( "OLE32", unicode )
- */
- public native static int CoInitialize( int pvReserved );
-
- /**
- * note that this method returns an HRESULT, the return value from the
- * system call.
- *
- * @dll.import( "OLE32", unicode )
- */
- public native static int CoInitializeEx( int pvReserved, int dwCoInit );
-
- /** @dll.import( "OLE32", auto ) */
- public native static void CoUninitialize();
-
- /** @dll.import( "OLE32", auto ) */
- public native static int CoGetCurrentProcess();
-
-
- /****** COM register/revoke/get class objects *****************************/
-
- /** @dll.import( "OLE32", ole ) */
- public native static IUnknown CoGetClassObject( _Guid rclsid, int
- dwClsContext, COSERVERINFO pServerInfo, _Guid riid );
-
- /** @dll.import( "OLE32", ole ) */
- public native static int CoRegisterClassObject( _Guid rclsid, IUnknown pUnk,
- int dwClsContext, int flags );
-
- /** @dll.import( "OLE32", ole ) */
- public native static void CoRevokeClassObject( int dwRegister );
-
- /** @dll.import( "OLE32", ole ) */
- public native static void CoResumeClassObjects();
-
- /** @dll.import( "OLE32", ole ) */
- public native static void CoSuspendClassObjects();
-
- /** @dll.import( "OLE32", auto ) */
- public native static int CoAddRefServerProcess();
-
- /** @dll.import( "OLE32", auto ) */
- public native static int CoReleaseServerProcess();
-
- /** @dll.import( "OLE32", ole ) */
- public native static _Guid CoGetPSClsid( _Guid riid );
-
- /** @dll.import( "OLE32", ole ) */
- public native static void CoRegisterPSClsid( _Guid riid, _Guid rclsid );
-
-
- /****** DCOM Call Security. ***********************************************/
-
- /** @dll.import( "OLE32", ole ) */
- public native static IUnknown CoGetCallContext( _Guid riid );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IUnknown CoCopyProxy( IUnknown pProxy );
-
- /** @dll.import( "OLE32", ole ) */
- public native static void CoImpersonateClient();
-
- /** @dll.import( "OLE32", ole ) */
- public native static void CoRevertToSelf();
-
- /** @dll.import( "OLE32", ole ) */
- public native static IUnknown CoSwitchCallContext( IUnknown pNewObject );
-
-
- /****** helpers for creating instances ************************************/
-
- /** @dll.import( "OLE32", ole ) */
- public native static IUnknown CoCreateInstance( _Guid rclsid, IUnknown
- pUnkOuter, int dwClsContext, _Guid riid );
-
-
- //TODO:
- /** @dll.import( "OLE32", ole ) */
- private native static void CoGetInstanceFromFile( COSERVERINFO pServerInfo,
- _Guid pClsid, IUnknown punkOuter, int dwClsCtx, int grfMode, String
- pwszName, int dwCount, MULTI_QI pResults );
-
- public static void CoGetInstanceFromFile( COSERVERINFO pServerInfo,
- _Guid pClsid, IUnknown punkOuter, int dwClsCtx, int grfMode, String
- pwszName, MULTI_QI[] pResults )
- {
- if( pResults.length == 1 )
- {
- CoGetInstanceFromFile( pServerInfo, pClsid, punkOuter,
- dwClsCtx, grfMode, pwszName, 1, pResults[ 0 ] );
- }
- else
- {
- throw new IllegalArgumentException( "currently, only 1-element MULTI_QI arrays can be used" );
- }
- }
-
-
- //TODO:
- /** @dll.import( "OLE32", ole ) */
- private native static void CoGetInstanceFromIStorage( COSERVERINFO
- pServerInfo, _Guid pClsid, IUnknown punkOuter, int dwClsCtx, IStorage
- pstg, int dwCount, MULTI_QI pResults );
-
- public static void CoGetInstanceFromIStorage( COSERVERINFO
- pServerInfo, _Guid pClsid, IUnknown punkOuter, int dwClsCtx, IStorage
- pstg, MULTI_QI[] pResults )
- {
- if( pResults.length == 1 )
- {
- CoGetInstanceFromIStorage( pServerInfo, pClsid, punkOuter,
- dwClsCtx, pstg, 1, pResults[ 0 ] );
- }
- else
- {
- throw new IllegalArgumentException( "currently, only 1-element MULTI_QI arrays can be used" );
- }
- }
-
-
- //TODO:
- /** @dll.import( "OLE32", ole ) */
- private native static void CoCreateInstanceEx( _Guid rclsid, IUnknown
- punkOuter, int dwClsCtx, COSERVERINFO pServerInfo, int dwCount,
- MULTI_QI pResults );
-
- public static void CoCreateInstanceEx( _Guid rclsid, IUnknown
- punkOuter, int dwClsCtx, COSERVERINFO pServerInfo, MULTI_QI[] pResults )
- {
- if( pResults.length == 1 )
- {
- CoCreateInstanceEx( rclsid, punkOuter, dwClsCtx, pServerInfo, 1, pResults[ 0 ] );
- }
- else
- {
- throw new IllegalArgumentException( "currently, only 1-element MULTI_QI arrays can be used" );
- }
- }
-
-
- /****** other helpers *****************************************************/
-
- /** @dll.import( "OLE32", ole ) */
- public native static String StringFromCLSID( _Guid rclsid );
-
- /** @dll.import( "OLE32", ole ) */
- public native static _Guid CLSIDFromString( String lpsz );
-
- /** @dll.import( "OLE32", ole ) */
- public native static String StringFromIID( _Guid riid );
-
- /** @dll.import( "OLE32", ole ) */
- public native static _Guid IIDFromString( String lpsz );
-
- /** @dll.import( "OLE32", auto ) */
- public native static boolean CoIsOle1Class( _Guid rclsid );
-
- /** @dll.import( "OLE32", ole ) */
- public native static String ProgIDFromCLSID( _Guid clsid );
-
- /** @dll.import( "OLE32", ole ) */
- public native static _Guid CLSIDFromProgID( String lpszProgID );
-
- /** @dll.import( "OLE32", unicode ) */
- public native static int StringFromGUID2( _Guid rguid, StringBuffer lpsz,
- int cbMax );
-
- /** @dll.import( "OLE32", ole ) */
- public native static _Guid CoCreateGuid();
-
-
- /****** TreatAs APIS ******************************************************/
-
- /** @dll.import( "OLE32", ole ) */
- public native static _Guid CoGetTreatAsClass( _Guid clsidOld );
-
- /** @dll.import( "OLE32", ole ) */
- public native static void CoTreatAsClass( _Guid clsidOld, _Guid clsidNew );
-
-
- /****** Default Memory Allocation *****************************************/
-
- /** @dll.import( "OLE32", auto ) */
- public native static int CoTaskMemAlloc( int cb );
-
- /** @dll.import( "OLE32", auto ) */
- public native static int CoTaskMemRealloc( int pv, int cb );
-
- /** @dll.import( "OLE32", auto ) */
- public native static void CoTaskMemFree( int pv );
-
-
- /****** Storage API Prototypes ********************************************/
-
- /** @dll.import( "OLE32", ole ) */
- public native static IStorage StgCreateDocfile( String pwcsName, int grfMode,
- int reserved );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IStorage StgOpenStorage( String pwcsName, IStorage
- pstgPriority, int grfMode, Object snbExclude, int reserved );
-
- /** @dll.import( "OLE32", unicode ) */
- public native static int StgIsStorageFile( String pwcsName );
-
- /** @dll.import( "OLE32", ole ) */
- public native static void StgSetTimes( String lpszName, long[] pctime,
- long[] patime, long[] pmtime );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IStorage StgOpenLayoutDocfile( String pwcsDfName, int
- grfMode, int reserved );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IStorage StgCreateStorageEx( String pwcsName, int
- grfMode, int stgfmt, int grfAttrs, int reserved1, int reserved2,
- _Guid riid );
-
-
- /****** Moniker APIs ******************************************************/
-
- /** @dll.import( "OLE32", ole ) */
- public native static IUnknown BindMoniker( IMoniker pmk, int grfOpt, _Guid
- iidResult );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IUnknown CoGetObject( String pszName, BIND_OPTS
- pBindOptions, _Guid riid );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IMoniker MkParseDisplayName( IBindCtx pbc, String
- szUserName, int[] pchEaten );
-
- /**
- * note that this method returns an HRESULT, the return value from the
- * system call.
- *
- * @dll.import( "OLE32", unicode )
- */
- public native static void MonikerRelativePathTo( IMoniker pmkSrc, IMoniker
- pmkDest, IMoniker[] ppmkRelPath, boolean dwReserved );
-
- /**
- * note that this method returns an HRESULT, the return value from the
- * system call.
- *
- * @dll.import( "OLE32", unicode )
- */
- public native static int MonikerCommonPrefixWith( IMoniker pmkThis,
- IMoniker pmkOther, IMoniker[] ppmkCommon );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IBindCtx CreateBindCtx( int reserved );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IMoniker CreateGenericComposite( IMoniker pmkFirst,
- IMoniker pmkRest );
-
- /** @dll.import( "OLE32", ole ) */
- public native static _Guid GetClassFile( String szFilename );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IMoniker CreateClassMoniker( _Guid rclsid );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IMoniker CreateFileMoniker( String lpszPathName );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IMoniker CreateItemMoniker( String lpszDelim, String
- lpszItem );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IMoniker CreateAntiMoniker();
-
- /** @dll.import( "OLE32", ole ) */
- public native static IMoniker CreatePointerMoniker( IUnknown punk );
-
- /** @dll.import( "OLE32", ole ) */
- public native static IRunningObjectTable GetRunningObjectTable( int
- reserved );
-
-
- /****** Storage Utility APIs **********************************************/
-
- /** @dll.import( "OLE32", ole ) */
- public native static IStream CreateStreamOnHGlobal(int hGlobal, boolean
- fDeleteOnRelease);
-
- /** @dll.import( "OLE32", ole ) */
- public native static int GetHGlobalFromStream(IStream pstm);
-
- /** @dll.import( "OLE32", ole ) */
- public native static ILockBytes CreateILockBytesOnHGlobal(int hGlobal,
- boolean fDeleteOnRelease);
-
- /** @dll.import( "OLE32", ole ) */
- public native static int GetHGlobalFromILockBytes(ILockBytes plkbyt);
- }
-