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);
		}
	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);
		}
	}
Пример #3
1
 static int IntToEnum(IntPtr L)
 {
     int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
     ForceMode o = (ForceMode)arg0;
     LuaScriptMgr.Push(L, o);
     return 1;
 }
Пример #4
1
 static int LogWarning(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 1);
     string arg0 = LuaScriptMgr.GetLuaString(L, 1);
     Util.LogWarning(arg0);
     return 0;
 }
Пример #5
1
		// 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;
		}
	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);
		}
	}
 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;
     }
 }
Пример #8
1
 static int CheckEnvironment(IntPtr L)
 {
     LuaScriptMgr.CheckArgsCount(L, 0);
     bool o = Util.CheckEnvironment();
     LuaScriptMgr.Push(L, o);
     return 1;
 }
 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);
     }
 }
 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);
     }
 }
Пример #11
1
 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);
     }
 }
Пример #12
1
 public static string GetProcessPath(IntPtr hwnd)
 {
     uint pid = 0;
     GetWindowThreadProcessId(hwnd, out pid);
     Process proc = Process.GetProcessById((int)pid);
     return proc.MainModule.FileName.ToString();
 }
Пример #13
1
    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);
    }
Пример #14
1
 internal static extern uint LsaLookupSids(
     SafeLsaPolicyHandle handle,
     int count,
     IntPtr[] sids,
     ref SafeLsaMemoryHandle referencedDomains,
     ref SafeLsaMemoryHandle names
     );
Пример #15
1
 private static extern bool UpdateResource(
     IntPtr hUpdate,
     string lpType,
     IntPtr intResource,
     ushort wLanguage,
     IntPtr lpData,
     uint cbData);
Пример #16
1
    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;
    }
Пример #17
1
	// 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;
	}
	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);
		}
	}
Пример #19
1
	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 int IntToEnum(IntPtr L)
 {
     int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
     UnityEngine.BlendWeights o = (UnityEngine.BlendWeights)arg0;
     ToLua.Push(L, o);
     return 1;
 }
	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);
		}
	}
Пример #22
1
 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");
 }
        // 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);
            }
        }
 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));
 }
Пример #25
1
		public void AssignHandle(IntPtr handle)
		{
			RemoveFromTable (this);
			window_handle = handle;
			AddToTable (this);
			OnHandleChange();
		}
	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);
	}
 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)
 {
     getEnumTable(l,"UnityEngine.Experimental.Director.PlayState");
     addMember(l,0,"Paused");
     addMember(l,1,"Playing");
     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;
 }
	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);
	}
Пример #31
0
 internal static extern void cveTextDetectorCNNRelease(ref IntPtr sharedPtr);
Пример #32
0
 public static extern int SHGetSpecialFolderLocation(IntPtr hwnd, int csidl, ref IntPtr ppidl);
 public MainApplication(IntPtr handle, JniHandleOwnership transer)
   :base(handle, transer)
 {
 }
Пример #34
0
 internal static extern bool DestroyWindow(IntPtr hwnd);
Пример #35
0
 internal static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
Пример #36
0
 internal static extern IntPtr GetDC(IntPtr hWnd);
Пример #37
0
 internal static extern int Close(IntPtr fd);
Пример #38
0
        public void SetServiceRecoveryOptions(HostSettings settings, ServiceRecoveryOptions options)
        {
            IntPtr scmHandle     = IntPtr.Zero;
            IntPtr serviceHandle = IntPtr.Zero;
            IntPtr lpsaActions   = IntPtr.Zero;
            IntPtr lpInfo        = IntPtr.Zero;
            IntPtr lpFlagInfo    = IntPtr.Zero;

            try
            {
                List <NativeMethods.SC_ACTION> actions = options.Actions.Select(x => x.GetAction()).ToList();
                if (actions.Count == 0)
                {
                    throw new TopshelfException("Must be at least one failure action configured");
                }

                scmHandle = NativeMethods.OpenSCManager(null, null, (int)NativeMethods.SCM_ACCESS.SC_MANAGER_ALL_ACCESS);
                if (scmHandle == IntPtr.Zero)
                {
                    throw new TopshelfException("Failed to open service control manager");
                }

                serviceHandle = NativeMethods.OpenService(scmHandle, settings.ServiceName,
                                                          (int)NativeMethods.SCM_ACCESS.SC_MANAGER_ALL_ACCESS);
                if (serviceHandle == IntPtr.Zero)
                {
                    throw new TopshelfException("Failed to open service: " + settings.ServiceName);
                }

                int actionSize = Marshal.SizeOf(typeof(NativeMethods.SC_ACTION));
                lpsaActions = Marshal.AllocHGlobal(actionSize * actions.Count + 1);
                if (lpsaActions == IntPtr.Zero)
                {
                    throw new TopshelfException("Unable to allocate memory for service recovery actions");
                }

                IntPtr nextAction = lpsaActions;
                for (int i = 0; i < actions.Count; i++)
                {
                    Marshal.StructureToPtr(actions[i], nextAction, false);
                    nextAction = (IntPtr)(nextAction.ToInt64() + actionSize);
                }

                var finalAction = new NativeMethods.SC_ACTION();
                finalAction.Type  = (int)NativeMethods.SC_ACTION_TYPE.None;
                finalAction.Delay = (int)TimeSpan.FromMinutes(1).TotalMilliseconds;

                Marshal.StructureToPtr(finalAction, nextAction, false);

                string rebootMessage = options.Actions.Where(x => x.GetType() == typeof(RestartSystemRecoveryAction))
                                       .OfType <RestartSystemRecoveryAction>().Select(x => x.RestartMessage).
                                       FirstOrDefault() ?? "";

                string runProgramCommand = options.Actions.Where(x => x.GetType() == typeof(RunProgramRecoveryAction))
                                           .OfType <RunProgramRecoveryAction>().Select(x => x.Command).
                                           FirstOrDefault() ?? "";


                var failureActions = new NativeMethods.SERVICE_FAILURE_ACTIONS();
                failureActions.dwResetPeriod =
                    (int)TimeSpan.FromDays(options.ResetPeriod).TotalSeconds;
                failureActions.lpRebootMsg = rebootMessage;
                failureActions.lpCommand   = runProgramCommand;
                failureActions.cActions    = actions.Count + 1;
                failureActions.actions     = lpsaActions;

                lpInfo = Marshal.AllocHGlobal(Marshal.SizeOf(failureActions));
                if (lpInfo == IntPtr.Zero)
                {
                    throw new TopshelfException("Failed to allocate memory for failure actions");
                }

                Marshal.StructureToPtr(failureActions, lpInfo, false);

                if (!NativeMethods.ChangeServiceConfig2(serviceHandle,
                                                        NativeMethods.SERVICE_CONFIG_FAILURE_ACTIONS, lpInfo))
                {
                    throw new TopshelfException("Failed to change service recovery options");
                }

                if (false == options.RecoverOnCrashOnly)
                {
                    var flag = new NativeMethods.SERVICE_FAILURE_ACTIONS_FLAG();
                    flag.fFailureActionsOnNonCrashFailures = true;

                    lpFlagInfo = Marshal.AllocHGlobal(Marshal.SizeOf(flag));
                    if (lpFlagInfo == IntPtr.Zero)
                    {
                        throw new TopshelfException("Failed to allocate memory for failure flag");
                    }

                    Marshal.StructureToPtr(flag, lpFlagInfo, false);

                    try
                    {
                        NativeMethods.ChangeServiceConfig2(serviceHandle,
                                                           NativeMethods.SERVICE_CONFIG_FAILURE_ACTIONS_FLAG, lpFlagInfo);
                    }
                    catch
                    {
                        // this fails on XP, but we don't care really as it's optional
                    }
                }
            }
            finally
            {
                if (lpFlagInfo != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(lpFlagInfo);
                }
                if (lpInfo != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(lpInfo);
                }
                if (lpsaActions != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(lpsaActions);
                }
                if (serviceHandle != IntPtr.Zero)
                {
                    NativeMethods.CloseServiceHandle(serviceHandle);
                }
                if (scmHandle != IntPtr.Zero)
                {
                    NativeMethods.CloseServiceHandle(scmHandle);
                }
            }
        }
Пример #39
0
 public static extern IntPtr SendMessage(HandleRef hWnd, uint msg, long wParam, IntPtr lParam);
Пример #40
0
 public static extern bool SHGetPathFromIDList(IntPtr pidl, IntPtr pszPath);
Пример #41
0
		static extern bool IsWindow(IntPtr hWnd);
Пример #42
0
        /// <summary>
        /// When overridden in a derived class, specifies a common dialog box.
        /// </summary>
        /// <param name="hwndOwner">A value that represents the window handle of the owner window for the common dialog box.</param>
        /// <returns>true if the dialog box was successfully run; otherwise, false.</returns>
        protected override bool RunDialog(IntPtr hwndOwner)
        {
            IntPtr root = IntPtr.Zero;
            bool flag = false;

            UnsafeNativeMethods.Shell32.SHGetSpecialFolderLocation(hwndOwner, (int)Environment.SpecialFolder.Desktop, ref root);

            int browseInfoFlags = NativeMethods.BIF_NEWDIALOGSTYLE;

            if (!_showNewFolderButton)
            {
                browseInfoFlags += NativeMethods.BIF_NONEWFOLDERBUTTON;
            }

            IntPtr pidl = IntPtr.Zero;
            IntPtr hglobal = IntPtr.Zero;
            IntPtr pszPath = IntPtr.Zero;

            try
            {
                hglobal = Marshal.AllocHGlobal((int)(260 * Marshal.SystemDefaultCharSize));
                pszPath = Marshal.AllocHGlobal((int)(260 * Marshal.SystemDefaultCharSize));
                _callback = new UnsafeNativeMethods.BrowseCallbackProc(OnBrowseCallbackProc);

                UnsafeNativeMethods.BROWSEINFO lpbi = new UnsafeNativeMethods.BROWSEINFO();

                lpbi.pidlRoot = root;
                lpbi.hwndOwner = hwndOwner;
                lpbi.pszDisplayName = hglobal;
                lpbi.lpszTitle = _descriptionText;
                lpbi.ulFlags = browseInfoFlags;
                lpbi.lpfn = _callback;
                lpbi.lParam = IntPtr.Zero;
                lpbi.iImage = 0;

                pidl = UnsafeNativeMethods.Shell32.SHBrowseForFolder(lpbi);

                if (pidl != IntPtr.Zero)
                {
                    UnsafeNativeMethods.Shell32.SHGetPathFromIDList(pidl, pszPath);
                    _selectedPathNeedsCheck = true;
                    _selectedPath = Marshal.PtrToStringAuto(pszPath);
                    flag = true;
                }
            }
            finally
            {
                UnsafeNativeMethods.IMalloc sHMalloc = GetSHMalloc();
                sHMalloc.Free(root);

                if (pidl != IntPtr.Zero)
                    sHMalloc.Free(pidl);
                if (pszPath != IntPtr.Zero)
                    Marshal.FreeHGlobal(pszPath);
                if (hglobal != IntPtr.Zero)
                    Marshal.FreeHGlobal(hglobal);

                _callback = null;
            }

            return flag;
        }
Пример #43
0
 internal static extern bool recv_ptz_white_balance_indoor_64(IntPtr p_instance);
Пример #44
0
 internal static extern IntPtr cveTextDetectorCNNCreate2(IntPtr modelArchFilename, IntPtr modelWeightsFilename, IntPtr detectionSizes, ref IntPtr sharedPtr);
Пример #45
0
 internal static extern bool recv_recording_get_times_32(IntPtr p_instance, ref recv_recording_time_t p_times);
Пример #46
0
 internal static extern void cveTextDetectorCNNDetect(IntPtr detector, IntPtr inputImage, IntPtr bbox, IntPtr confidence);
Пример #47
0
 internal static extern IntPtr recv_recording_get_filename_32(IntPtr p_instance);
Пример #48
0
 /// <summary>
 /// Gets the delegate.
 /// </summary>
 private static void GetDelegate <T>(IntPtr ptr, out T del)
 {
     del = (T)(object)Marshal.GetDelegateForFunctionPointer(ptr, typeof(T));
 }
Пример #49
0
 internal static extern bool recv_recording_set_audio_level_32(IntPtr p_instance, float level_dB);
Пример #50
0
 internal static extern IntPtr recv_recording_get_error_32(IntPtr p_instance);
Пример #51
0
 internal static extern bool recv_recording_start_32(IntPtr p_instance, IntPtr p_filename_hint);
Пример #52
0
 internal static extern bool recv_recording_is_recording_32(IntPtr p_instance);
Пример #53
0
 internal static extern bool recv_ptz_exposure_auto_32(IntPtr p_instance);
Пример #54
0
 internal static extern bool recv_recording_stop_64(IntPtr p_instance);
Пример #55
0
 internal static extern bool recv_ptz_white_balance_oneshot_32(IntPtr p_instance);
Пример #56
0
 internal static extern bool recv_ptz_exposure_manual_32(IntPtr p_instance, float exposure_level);
Пример #57
0
 internal static extern bool recv_ptz_focus_speed_32(IntPtr p_instance, float focus_speed);
Пример #58
0
 internal static extern bool recv_ptz_white_balance_manual_32(IntPtr p_instance, float red, float blue);
Пример #59
0
 internal static extern bool recv_ptz_focus_32(IntPtr p_instance, float focus_value);
Пример #60
0
 internal static extern bool recv_ptz_white_balance_outdoor_32(IntPtr p_instance);