api.cs

来自「利用C#实现的将Word文件转换为PDF的源代码。其中转换过程分为3步」· CS 代码 · 共 85 行

CS
85
字号
/*
 * EBI-Software all rights reserved.
 * webmaster@ebi-software.de
 * This code is only for educational use.
 */

using System;
using System.Runtime;
using System.Drawing;
using System.Runtime.InteropServices;

namespace EBIsagt.Windows.API
{
	public class User32
	{
		[DllImport("User32.dll", CharSet=CharSet.Auto)]
		public static extern int SendMessage(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam);
	}
	
	public class Ole32
	{


		[DllImport("ole32.dll")] 
		public static extern int ProgIDFromCLSID( 
			ref Guid clsid, 
			out string lplpszProgID
			); 

		[DllImport("ole32.dll")]
		public static extern int CreateStreamOnHGlobal( 
			int hGlobalMemHandle,
			bool fDeleteOnRelease,
			out UCOMIStream pOutStm
			);

		[DllImport("ole32.dll")]
		public static extern int CoRevokeClassObject(int dwRegister);

		[ DllImport ( "Ole32.Dll" ) ]
		public static extern int CreateBindCtx ( int reserved, out UCOMIBindCtx
			bindCtx );

		[DllImport("ole32.dll")]
		public static extern int CoImpersonateClient () ;


		[DllImport("OLE32.DLL", CharSet=CharSet.Auto)]
		public static extern uint CoRevertToSelf();

		[DllImport("OLE32.DLL", CharSet=CharSet.Auto)] 
		public static extern uint CoSetProxyBlanket( 
			IntPtr pProxy,
			uint dwAuthnSvc,
			uint dwAuthzSvc,
			IntPtr pServerPrincName,
			uint dwAuthnLevel,
			uint dwImpLevel,
			IntPtr pAuthInfo,
			uint dwCapababilities);

		[DllImport("ole32.dll")]
		public static extern int OleDraw(IntPtr pUnk, int dwAspect, IntPtr hdcDraw, ref Rectangle lprcBounds);

		[DllImport("ole32.dll")]
		public static extern Int32 CoInitialize ([ MarshalAs( UnmanagedType.AsAny )] Object o);

		[DllImport("ole32.dll", EntryPoint="CoImpersonateClient")]
		public extern static int CoImpersonateClient1();

		[DllImport("ole32.dll", EntryPoint="CoImpersonateClient")]
		public extern static void CoImpersonateClient2();



	}

	public class Messages
	{
		public const int WM_USER = 0x0400;
		public const int EM_FORMATRANGE  = WM_USER + 57;
		public const int EM_GETOLEINTERFACE = WM_USER + 60;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?