C# (CSharp) IntPtr Code Examples

C# (CSharp) IntPtr - 30 примеров найдено. Это лучшие примеры C# (CSharp) кода для IntPtr, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
Пример #1
0
	// Usually called when cloning images that need to have
	// not only the handle saved, but also the underlying stream
	// (when using MS GDI+ and IStream we must ensure the stream stays alive for all the life of the Image)
	internal Metafile (IntPtr ptr, Stream stream)
	{
		// under Win32 stream is owned by SD/GDI+ code
		if (GDIPlus.RunningOnWindows ())
			this.stream = stream;
		nativeObject = ptr;
	}
Пример #2
0
 static int CheckEnvironment(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 0);
     bool o = Util.CheckEnvironment();
     LuaScriptMgr.Push(L, o);
     return 1;
 }
	static public int SetEnabledFading(IntPtr l) {
		try {
			int argc = LuaDLL.lua_gettop(l);
			if(argc==2){
				UnityEngine.Cloth self=(UnityEngine.Cloth)checkSelf(l);
				System.Boolean a1;
				checkType(l,2,out a1);
				self.SetEnabledFading(a1);
				pushValue(l,true);
				return 1;
			}
			else if(argc==3){
				UnityEngine.Cloth self=(UnityEngine.Cloth)checkSelf(l);
				System.Boolean a1;
				checkType(l,2,out a1);
				System.Single a2;
				checkType(l,3,out a2);
				self.SetEnabledFading(a1,a2);
				pushValue(l,true);
				return 1;
			}
			pushValue(l,false);
			LuaDLL.lua_pushstring(l,"No matched override function to call");
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
Пример #4
0
 public static string GetProcessPath(IntPtr hwnd)
 {
     uint pid = 0;
     GetWindowThreadProcessId(hwnd, out pid);
     Process proc = Process.GetProcessById((int)pid);
     return proc.MainModule.FileName.ToString();
 }
 public static int AddMatrix(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if(matchType(l,argc,2,typeof(int),typeof(UnityEngine.Matrix4x4))){
             UnityEngine.MaterialPropertyBlock self=(UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l,2,out a1);
             UnityEngine.Matrix4x4 a2;
             checkValueType(l,3,out a2);
             self.AddMatrix(a1,a2);
             pushValue(l,true);
             return 1;
         }
         else if(matchType(l,argc,2,typeof(string),typeof(UnityEngine.Matrix4x4))){
             UnityEngine.MaterialPropertyBlock self=(UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l,2,out a1);
             UnityEngine.Matrix4x4 a2;
             checkValueType(l,3,out a2);
             self.AddMatrix(a1,a2);
             pushValue(l,true);
             return 1;
         }
         pushValue(l,false);
         LuaDLL.lua_pushstring(l,"No matched override function to call");
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
Пример #6
0
    static int AddChild(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1)
        {
            GameObject arg0 = (GameObject)LuaScriptMgr.GetUnityObject(L, 1, typeof(GameObject));
            GameObject o = NGUITools.AddChild(arg0);
            LuaScriptMgr.Push(L, o);
            return 1;
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(GameObject)))
        {
            GameObject arg0 = (GameObject)LuaScriptMgr.GetLuaObject(L, 1);
            GameObject arg1 = (GameObject)LuaScriptMgr.GetLuaObject(L, 2);
            GameObject o = NGUITools.AddChild(arg0,arg1);
            LuaScriptMgr.Push(L, o);
            return 1;
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(bool)))
        {
            GameObject arg0 = (GameObject)LuaScriptMgr.GetLuaObject(L, 1);
            bool arg1 = LuaDLL.lua_toboolean(L, 2);
            GameObject o = NGUITools.AddChild(arg0,arg1);
            LuaScriptMgr.Push(L, o);
            return 1;
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: NGUITools.AddChild");
        }

        return 0;
    }
Пример #7
0
 internal static extern uint LsaLookupSids(
     SafeLsaPolicyHandle handle,
     int count,
     IntPtr[] sids,
     ref SafeLsaMemoryHandle referencedDomains,
     ref SafeLsaMemoryHandle names
     );
        // The app name should either be a valid app name or be 'null' to get the state service
        // counters initialized
        private static void OpenCounter(string appName) {
            try {
                // Don't activate perf counters if webengine.dll isn't loaded
                if (! HttpRuntime.IsEngineLoaded) 
                    return;

                // Open the global counters
                if (_global == IntPtr.Zero) {
                    _global = UnsafeNativeMethods.PerfOpenGlobalCounters();
                }

                // If appName is null, then we want the state counters
                if (appName == null) {
                    if (_stateService == IntPtr.Zero) {
                        _stateService = UnsafeNativeMethods.PerfOpenStateCounters();
                    }
                }
                else {
                    if (appName != null) {
                        _instance = UnsafeNativeMethods.PerfOpenAppCounters(appName);
                    }
                }
            }
            catch (Exception e) {
                Debug.Trace("Perfcounters", "Exception: " + e.StackTrace);
            }
        }
	static public void reg(IntPtr l) {
		getEnumTable(l,"UnityEngine.ColorSpace");
		addMember(l,0,"Gamma");
		addMember(l,1,"Linear");
		addMember(l,-1,"Uninitialized");
		LuaDLL.lua_pop(l, 1);
	}
 public static void reg(IntPtr l)
 {
     getTypeTable(l,"UnityEngine.AvatarBuilder");
     addMember(l,BuildHumanAvatar_s);
     addMember(l,BuildGenericAvatar_s);
     createTypeMetatable(l,constructor, typeof(UnityEngine.AvatarBuilder));
 }
 public static void reg(IntPtr l)
 {
     getTypeTable(l,"UnityEngine.AudioHighPassFilter");
     addMember(l,"cutoffFrequency",get_cutoffFrequency,set_cutoffFrequency,true);
     addMember(l,"highpassResonanceQ",get_highpassResonanceQ,set_highpassResonanceQ,true);
     createTypeMetatable(l,constructor, typeof(UnityEngine.AudioHighPassFilter),typeof(UnityEngine.Behaviour));
 }
	static public void reg(IntPtr l) {
		getEnumTable(l,"UnityEngine.BlendWeights");
		addMember(l,1,"OneBone");
		addMember(l,2,"TwoBones");
		addMember(l,4,"FourBones");
		LuaDLL.lua_pop(l, 1);
	}
 static int IntToEnum(IntPtr L)
 {
     int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
     OffMeshLinkType o = (OffMeshLinkType)arg0;
     LuaScriptMgr.Push(L, o);
     return 1;
 }
 public static void reg(IntPtr l)
 {
     getEnumTable(l,"UnityEngine.Experimental.Director.PlayState");
     addMember(l,0,"Paused");
     addMember(l,1,"Playing");
     LuaDLL.lua_pop(l, 1);
 }
Пример #15
0
	public static bool SendFileToPrinter( string szPrinterName, string szFileName )
	{
		// Open the file.
		FileStream fs = new FileStream(szFileName, FileMode.Open);
		// Create a BinaryReader on the file.
		BinaryReader br = new BinaryReader(fs);
		// Dim an array of bytes big enough to hold the file's contents.
		Byte []bytes = new Byte[fs.Length];
		bool bSuccess = false;
		// Your unmanaged pointer.
		IntPtr pUnmanagedBytes = new IntPtr(0);
		int nLength;

		nLength = Convert.ToInt32(fs.Length);
		// Read the contents of the file into the array.
		bytes = br.ReadBytes( nLength );
		// Allocate some unmanaged memory for those bytes.
		pUnmanagedBytes = Marshal.AllocCoTaskMem(nLength);
		// Copy the managed byte array into the unmanaged array.
		Marshal.Copy(bytes, 0, pUnmanagedBytes, nLength);
		// Send the unmanaged bytes to the printer.
		bSuccess = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, nLength);
		// Free the unmanaged memory that you allocated earlier.
		Marshal.FreeCoTaskMem(pUnmanagedBytes);
		return bSuccess;
	}
	static public int GetFloat(IntPtr l) {
		try {
			int argc = LuaDLL.lua_gettop(l);
			if(matchType(l,argc,2,typeof(int))){
				UnityEngine.Animator self=(UnityEngine.Animator)checkSelf(l);
				System.Int32 a1;
				checkType(l,2,out a1);
				var ret=self.GetFloat(a1);
				pushValue(l,true);
				pushValue(l,ret);
				return 2;
			}
			else if(matchType(l,argc,2,typeof(string))){
				UnityEngine.Animator self=(UnityEngine.Animator)checkSelf(l);
				System.String a1;
				checkType(l,2,out a1);
				var ret=self.GetFloat(a1);
				pushValue(l,true);
				pushValue(l,ret);
				return 2;
			}
			pushValue(l,false);
			LuaDLL.lua_pushstring(l,"No matched override function to call");
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
Пример #17
0
 private static extern bool UpdateResource(
     IntPtr hUpdate,
     string lpType,
     IntPtr intResource,
     ushort wLanguage,
     IntPtr lpData,
     uint cbData);
Пример #18
0
 public object WithRefsWithReturn(
     ref string param1,
     ref int param2,
     ref short param3,
     ref long param4,
     ref uint param5,
     ref ushort param6,
     ref ulong param7,
     ref bool param8,
     ref double param9,
     ref decimal param10,
     ref int? param11,
     ref object param12,
     ref char param13,
     ref DateTime param14,
     ref Single param15,
     ref IntPtr param16,
     ref UInt16 param17,
     ref UInt32 param18,
     ref UInt64 param19,
     ref UIntPtr param20
     )
 {
     throw new Exception("Foo");
 }
Пример #19
0
    public static void Register(IntPtr L)
    {
        LuaMethod[] regs = new LuaMethod[]
        {
            new LuaMethod("Lerp", Lerp),
            new LuaMethod("ClampIndex", ClampIndex),
            new LuaMethod("RepeatIndex", RepeatIndex),
            new LuaMethod("WrapAngle", WrapAngle),
            new LuaMethod("Wrap01", Wrap01),
            new LuaMethod("HexToDecimal", HexToDecimal),
            new LuaMethod("DecimalToHexChar", DecimalToHexChar),
            new LuaMethod("DecimalToHex24", DecimalToHex24),
            new LuaMethod("DecimalToHex32", DecimalToHex32),
            new LuaMethod("ColorToInt", ColorToInt),
            new LuaMethod("IntToColor", IntToColor),
            new LuaMethod("IntToBinary", IntToBinary),
            new LuaMethod("HexToColor", HexToColor),
            new LuaMethod("ConvertToTexCoords", ConvertToTexCoords),
            new LuaMethod("ConvertToPixels", ConvertToPixels),
            new LuaMethod("MakePixelPerfect", MakePixelPerfect),
            new LuaMethod("ConstrainRect", ConstrainRect),
            new LuaMethod("SpringDampen", SpringDampen),
            new LuaMethod("SpringLerp", SpringLerp),
            new LuaMethod("RotateTowards", RotateTowards),
            new LuaMethod("DistanceToRectangle", DistanceToRectangle),
            new LuaMethod("AdjustByDPI", AdjustByDPI),
            new LuaMethod("ScreenToPixels", ScreenToPixels),
            new LuaMethod("ScreenToParentPixels", ScreenToParentPixels),
            new LuaMethod("New", _CreateNGUIMath),
            new LuaMethod("GetClassType", GetClassType),
        };

        LuaScriptMgr.RegisterLib(L, "NGUIMath", regs);
    }
	static int RectangleContainsScreenPoint(IntPtr L)
	{
		try
		{
			int count = LuaDLL.lua_gettop(L);

			if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.RectTransform), typeof(UnityEngine.Vector2)))
			{
				UnityEngine.RectTransform arg0 = (UnityEngine.RectTransform)ToLua.ToObject(L, 1);
				UnityEngine.Vector2 arg1 = ToLua.ToVector2(L, 2);
				bool o = UnityEngine.RectTransformUtility.RectangleContainsScreenPoint(arg0, arg1);
				LuaDLL.lua_pushboolean(L, o);
				return 1;
			}
			else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.RectTransform), typeof(UnityEngine.Vector2), typeof(UnityEngine.Camera)))
			{
				UnityEngine.RectTransform arg0 = (UnityEngine.RectTransform)ToLua.ToObject(L, 1);
				UnityEngine.Vector2 arg1 = ToLua.ToVector2(L, 2);
				UnityEngine.Camera arg2 = (UnityEngine.Camera)ToLua.ToObject(L, 3);
				bool o = UnityEngine.RectTransformUtility.RectangleContainsScreenPoint(arg0, arg1, arg2);
				LuaDLL.lua_pushboolean(L, o);
				return 1;
			}
			else
			{
				return LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.RectTransformUtility.RectangleContainsScreenPoint");
			}
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}
Пример #21
0
 public static int Clear(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if(argc==1){
             UnityEngine.Mesh self=(UnityEngine.Mesh)checkSelf(l);
             self.Clear();
             pushValue(l,true);
             return 1;
         }
         else if(argc==2){
             UnityEngine.Mesh self=(UnityEngine.Mesh)checkSelf(l);
             System.Boolean a1;
             checkType(l,2,out a1);
             self.Clear(a1);
             pushValue(l,true);
             return 1;
         }
         pushValue(l,false);
         LuaDLL.lua_pushstring(l,"No matched override function to call");
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
 static int IntToEnum(IntPtr L)
 {
     int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
     UnityEngine.BlendWeights o = (UnityEngine.BlendWeights)arg0;
     ToLua.Push(L, o);
     return 1;
 }
Пример #23
0
 public static int GetFloat_s(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if(argc==1){
             System.String a1;
             checkType(l,1,out a1);
             var ret=UnityEngine.PlayerPrefs.GetFloat(a1);
             pushValue(l,true);
             pushValue(l,ret);
             return 2;
         }
         else if(argc==2){
             System.String a1;
             checkType(l,1,out a1);
             System.Single a2;
             checkType(l,2,out a2);
             var ret=UnityEngine.PlayerPrefs.GetFloat(a1,a2);
             pushValue(l,true);
             pushValue(l,ret);
             return 2;
         }
         pushValue(l,false);
         LuaDLL.lua_pushstring(l,"No matched override function to call");
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
		internal OleDbTransaction (OleDbConnection connection, int depth, IsolationLevel isolevel) 
		{
			this.connection = connection;

			gdaTransaction = libgda.gda_transaction_new (depth.ToString ());
			
			switch (isolevel) {
			case IsolationLevel.ReadCommitted :
				libgda.gda_transaction_set_isolation_level (gdaTransaction,
									    GdaTransactionIsolation.ReadCommitted);
				break;
			case IsolationLevel.ReadUncommitted :
				libgda.gda_transaction_set_isolation_level (gdaTransaction,
									    GdaTransactionIsolation.ReadUncommitted);
				break;
			case IsolationLevel.RepeatableRead :
				libgda.gda_transaction_set_isolation_level (gdaTransaction,
									    GdaTransactionIsolation.RepeatableRead);
				break;
			case IsolationLevel.Serializable :
				libgda.gda_transaction_set_isolation_level (gdaTransaction,
									    GdaTransactionIsolation.Serializable);
				break;
			}
			
			libgda.gda_connection_begin_transaction (connection.GdaConnection, gdaTransaction);
		}
 public static int AddRelativeForce(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if(argc==2){
             UnityEngine.Rigidbody2D self=(UnityEngine.Rigidbody2D)checkSelf(l);
             UnityEngine.Vector2 a1;
             checkType(l,2,out a1);
             self.AddRelativeForce(a1);
             return 0;
         }
         else if(argc==3){
             UnityEngine.Rigidbody2D self=(UnityEngine.Rigidbody2D)checkSelf(l);
             UnityEngine.Vector2 a1;
             checkType(l,2,out a1);
             UnityEngine.ForceMode2D a2;
             checkEnum(l,3,out a2);
             self.AddRelativeForce(a1,a2);
             return 0;
         }
         LuaDLL.luaL_error(l,"No matched override function to call");
         return 0;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
Пример #26
0
	public void AssignHandle(IntPtr handle)
	{
		RemoveFromTable (this);
		window_handle = handle;
		AddToTable (this);
		OnHandleChange();
	}
Пример #27
0
 static int LogWarning(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 1);
     string arg0 = LuaScriptMgr.GetLuaString(L, 1);
     Util.LogWarning(arg0);
     return 0;
 }
Пример #28
0
	// SendBytesToPrinter()
	// When the function is given a printer name and an unmanaged array
	// of bytes, the function sends those bytes to the print queue.
	// Returns true on success, false on failure.
	public static bool SendBytesToPrinter( string szPrinterName, IntPtr pBytes, Int32 dwCount)
	{
		Int32    dwError = 0, dwWritten = 0;
		IntPtr    hPrinter = new IntPtr(0);
		DOCINFOA    di = new DOCINFOA();
		bool    bSuccess = false; // Assume failure unless you specifically succeed.

		di.pDocName = "My C#.NET RAW Document";
		di.pDataType = "RAW";

		// Open the printer.
		if( OpenPrinter( szPrinterName, out hPrinter, 0 ) )
		{
			// Start a document.
			if( StartDocPrinter(hPrinter, 1, di) )
			{
				// Start a page.
				if( StartPagePrinter(hPrinter) )
				{
					// Write your bytes.
					bSuccess = WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
					EndPagePrinter(hPrinter);
				}
				EndDocPrinter(hPrinter);
			}
			ClosePrinter(hPrinter);
		}
		// If you did not succeed, GetLastError may give more information
		// about why not.
		if( bSuccess == false )
		{
			dwError = Marshal.GetLastWin32Error();
		}
		return bSuccess;
	}
Пример #29
0
 static int IntToEnum(IntPtr L)
 {
     int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
     ForceMode o = (ForceMode)arg0;
     LuaScriptMgr.Push(L, o);
     return 1;
 }
	static public int RectangleContainsScreenPoint_s(IntPtr l) {
		try {
			int argc = LuaDLL.lua_gettop(l);
			if(argc==2){
				UnityEngine.RectTransform a1;
				checkType(l,1,out a1);
				UnityEngine.Vector2 a2;
				checkType(l,2,out a2);
				var ret=UnityEngine.RectTransformUtility.RectangleContainsScreenPoint(a1,a2);
				pushValue(l,true);
				pushValue(l,ret);
				return 2;
			}
			else if(argc==3){
				UnityEngine.RectTransform a1;
				checkType(l,1,out a1);
				UnityEngine.Vector2 a2;
				checkType(l,2,out a2);
				UnityEngine.Camera a3;
				checkType(l,3,out a3);
				var ret=UnityEngine.RectTransformUtility.RectangleContainsScreenPoint(a1,a2,a3);
				pushValue(l,true);
				pushValue(l,ret);
				return 2;
			}
			pushValue(l,false);
			LuaDLL.lua_pushstring(l,"No matched override function to call");
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}