コード例 #1
0
 /// <summary>
 /// Send file to recycle bin
 /// </summary>
 /// <param name="path">Location of directory or file to recycle</param>
 /// <param name="flags">FileOperationFlags to add in addition to FOF_ALLOWUNDO</param>
 public static bool Send(string path, NativeMethods.FileOperationFlags flags)
 {
     try
     {
         if (NativeMethods.IsWOW64Process())
         {
             NativeMethods.SHFILEOPSTRUCT_x64 fs = new NativeMethods.SHFILEOPSTRUCT_x64();
             fs.wFunc = NativeMethods.FileOperationType.FO_DELETE;
             // important to double-terminate the string.
             fs.pFrom = path + '\0' + '\0';
             fs.fFlags = NativeMethods.FileOperationFlags.FOF_ALLOWUNDO | flags;
             NativeMethods.SHFileOperation_x64(ref fs);
         }
         else
         {
             NativeMethods.SHFILEOPSTRUCT_x86 fs = new NativeMethods.SHFILEOPSTRUCT_x86();
             fs.wFunc = NativeMethods.FileOperationType.FO_DELETE;
             // important to double-terminate the string.
             fs.pFrom = path + '\0' + '\0';
             fs.fFlags = NativeMethods.FileOperationFlags.FOF_ALLOWUNDO | flags;
             NativeMethods.SHFileOperation_x86(ref fs);
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #2
0
        public static int HookCallback(int code, int wParam, ref NativeMethods.keyboardHookStruct lParam)
        {
            //Debug.WriteLine(code + " " + wParam + "  " + lParam.vkCode + " " + lParam.scanCode + " " + lParam.flags);

            if (code >= 0 && wParam == 256) // KeyDown
            {
                if ((!KeysDown.ContainsKey(lParam.vkCode) ||
                    KeysDown[lParam.vkCode] == false) &&
                    ShouldCancelKeyDown(lParam.vkCode))
                {
                    return 0;
                }

                KeysDown[lParam.vkCode] = true;
            }

            if (code >= 0 && wParam == 257) // KeyUp
            {
                KeysDown[lParam.vkCode] = false;
                if (ShouldCancelKeyUp(lParam.vkCode))
                    return 0;
            }

            return NativeMethods.CallNextHookEx(NextHookPointer, code, wParam, ref lParam);
        }
コード例 #3
0
 internal WinPosition(NativeMethods.TITLEBARINFO pti)
     {
     this.Left = pti.rcTitleBar.left;
     this.Top = pti.rcTitleBar.top;
     this.Right = pti.rcTitleBar.right;
     this.Bottom = pti.rcTitleBar.bottom;
     }
コード例 #4
0
 internal CategoryEntry(NativeMethods.PERF_OBJECT_TYPE perfObject)
 {
     this.NameIndex = perfObject.ObjectNameTitleIndex;
     this.HelpIndex = perfObject.ObjectHelpTitleIndex;
     this.CounterIndexes = new int[perfObject.NumCounters];
     this.HelpIndexes = new int[perfObject.NumCounters];
 }
コード例 #5
0
 internal WinPosition(NativeMethods.WINDOWINFO wti)
     {
     this.Left = wti.rcClient.left;
     this.Top = wti.rcClient.top;
     this.Right = wti.rcClient.right;
     this.Bottom = wti.rcClient.bottom;
     }
コード例 #6
0
ファイル: BackupStreamInfo.cs プロジェクト: Sicos1977/AlphaFS
 /// <summary>
 /// Initializes a new instance of the <see cref="BackupStreamInfo"/> class.
 /// </summary>
 /// <param name="streamID">The stream ID.</param>
 /// <param name="name">The name.</param>
 internal BackupStreamInfo(NativeMethods.WIN32_STREAM_ID streamID, string name)
 {
    m_size = (long)streamID.StreamSize;
    m_name = name;
    m_attributes = (StreamAttributes)streamID.StreamAttributes;
    m_streamType = (BackupStreamType)streamID.StreamType;
 }
コード例 #7
0
 internal IconHandleInfo(NativeMethods.ICONINFO info)
 {
     this.IsIcon = info.fIcon;
     this.Hotspot = new Point(info.xHotspot, info.yHotspot);
     this.MaskBitmap = new BitmapHandle(info.hbmMask);
     this.ColorBitmap = new BitmapHandle(info.hbmColor);
 }
 private static void ThrowWhenFailed(NativeMethods.ExecutionStates previousState)
 {
     if (previousState == 0)
     {
         throw new Exception("Failed to suppress/restore system power management.");
     }
 }
 public static void DrawText(this VisualStyleRenderer rnd, IDeviceContext dc, ref Rectangle bounds, string text, System.Windows.Forms.TextFormatFlags flags, NativeMethods.DrawThemeTextOptions options)
 {
     NativeMethods.RECT rc = new NativeMethods.RECT(bounds);
     using (SafeGDIHandle hdc = new SafeGDIHandle(dc))
         NativeMethods.DrawThemeTextEx(rnd.Handle, hdc, rnd.Part, rnd.State, text, text.Length, (int)flags, ref rc, ref options);
     bounds = rc;
 }
コード例 #10
0
 public static AsciiStringSearchAlgorithm CreateSearchAlgo(string pattern, NativeMethods.SearchOptions searchOptions)
 {
     if (pattern.Length <= 64)
     return new AsciiStringSearchBndm64(pattern, searchOptions);
       else
     return new AsciiStringSearchBoyerMoore(pattern, searchOptions);
 }
コード例 #11
0
 internal PluggableProtocolResponse(
     PluggableProtocolHandler handler,
     NativeMethods.IInternetProtocolSink sink )
 {
     this.handler=handler;
     this.m_Sink=sink;
 }
コード例 #12
0
        internal static unsafe uint ControlCallback(NativeMethods.WMIDPREQUESTCODE RequestCode, IntPtr Context, uint* InOutBufferSize, IntPtr Buffer)
        {
            uint Status;

            switch (RequestCode)
            {

                case NativeMethods.WMIDPREQUESTCODE.WMI_ENABLE_EVENTS:

                    hTraceLog = NativeMethods.GetTraceLoggerHandle(Buffer);

                    Status = NativeMethods.ERROR_SUCCESS;

                    break;

                case NativeMethods.WMIDPREQUESTCODE.WMI_DISABLE_EVENTS:

                    hTraceLog = 0;

                    Status = NativeMethods.ERROR_SUCCESS;

                    break;

                default:

                    Status = NativeMethods.ERROR_INVALID_PARAMETER;

                    break;

            }
            *InOutBufferSize = 0;

            return Status;
        }
コード例 #13
0
        /// <summary>Text updating message.</summary>
		/// <remarks>The string will be marshaled: the Message must be correctly disposed after use.</remarks>
        public Message(NativeMethods.TaskDialogMessages msg, DialogElements element, string s) {
            MessageType = msg;
            wParam = (int)element;

            _unsafeHandle = Marshal.StringToHGlobalUni(s);
            lParam = (int)_unsafeHandle;
        }
 private bool GetBuilderGuidString(NativeMethods.IProvidePropertyBuilder target, int dispid, ref string strGuidBldr, int[] bldrType)
 {
     bool builderAvailable = false;
     string[] pbstrGuidBldr = new string[1];
     if (NativeMethods.Failed(target.MapPropertyToBuilder(dispid, bldrType, pbstrGuidBldr, ref builderAvailable)))
     {
         builderAvailable = false;
     }
     if (builderAvailable && ((bldrType[0] & 2) == 0))
     {
         builderAvailable = false;
     }
     if (!builderAvailable)
     {
         return false;
     }
     if (pbstrGuidBldr[0] == null)
     {
         strGuidBldr = Guid.Empty.ToString();
     }
     else
     {
         strGuidBldr = pbstrGuidBldr[0];
     }
     return true;
 }
コード例 #15
0
		/// <summary>
		/// Get HID attributes.
		/// </summary>
		/// <param name="hidHandle"> HID handle retrieved with CreateFile </param>
		/// <param name="deviceAttributes"> HID attributes structure </param>
		/// <returns> true on success </returns>

		internal Boolean GetAttributes(SafeFileHandle hidHandle, ref NativeMethods.HIDD_ATTRIBUTES deviceAttributes)
		{
			Boolean success;
			try
			{
				//  ***
				//  API function:
				//  HidD_GetAttributes

				//  Purpose:
				//  Retrieves a HIDD_ATTRIBUTES structure containing the Vendor ID, 
				//  Product ID, and Product Version Number for a device.

				//  Accepts:
				//  A handle returned by CreateFile.
				//  A pointer to receive a HIDD_ATTRIBUTES structure.

				//  Returns:
				//  True on success, False on failure.
				//  ***                            

				success = NativeMethods.HidD_GetAttributes(hidHandle, ref deviceAttributes);
			}

			catch (Exception ex)
			{
				DisplayException(ModuleName, ex);
				throw;
			}
			return success;
		}
コード例 #16
0
ファイル: SQLiteStatement.cs プロジェクト: evlinsky/FBReader
        public void Compile()
        {
            if (_Command.Connection == null || _Command.Connection.State == ConnectionState.Closed || _Command.Connection.State == ConnectionState.Broken)
            {
                throw new InvalidOperationException("Connection is currently executing an operation.");
            }

            if (_NativeMethods == null) _NativeMethods = _Command.Connection.NativeMethods;

            if (!_FirstStep)
            {
                Reset();
            }
            else
            {
                if (_CommandText.Length == 0) throw new InvalidOperationException("The command text cannot be empty.");

                IntPtr pTail;
                IntPtr pVM;
                _NativeMethods.prepare(_CommandText, out pVM, out pTail);

                if (_NativeMethods.ErrorCode() != SQLiteCode.Ok)
                {
                    throw new SQLiteException(string.Format("Error while prepare statement {0}.\r\n {1}", _CommandText, _NativeMethods.ErrorMessage()));
                }

                _StatementHandle = pVM;
            }

            BindParameters();
        }
コード例 #17
0
        internal override NativeMethods.FOS GetDerivedOptionFlags(NativeMethods.FOS flags)
        {
            if (multiselect)
                flags |= NativeMethods.FOS.FOS_ALLOWMULTISELECT;
            // TODO: other flags

            return flags;
        }
コード例 #18
0
 internal BluetoothDevice(BluesoleilService owner, NativeMethods.BLUETOOTH_DEVICE_INFO deviceInfo)
 {
     this.owner = owner;
     this.deviceInfo = deviceInfo;
     int zeroIndex = Array.IndexOf<byte>(deviceInfo.szName, 0);
     this.name = Encoding.ASCII.GetString(deviceInfo.szName, 0, zeroIndex);
     address = deviceInfo.address;
 }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DotRas.RasCompressionOptions"/> class.
 /// </summary>
 /// <param name="value">The flags value to set.</param>
 internal RasCompressionOptions(NativeMethods.RASCCPO value)
 {
     this.CompressionOnly = Utilities.HasFlag(value, NativeMethods.RASCCPO.CompressionOnly);
     this.HistoryLess = Utilities.HasFlag(value, NativeMethods.RASCCPO.HistoryLess);
     this.Encryption56Bit = Utilities.HasFlag(value, NativeMethods.RASCCPO.Encryption56Bit);
     this.Encryption40Bit = Utilities.HasFlag(value, NativeMethods.RASCCPO.Encryption40Bit);
     this.Encryption128Bit = Utilities.HasFlag(value, NativeMethods.RASCCPO.Encryption128Bit);
 }
コード例 #20
0
ファイル: SQLiteString.cs プロジェクト: evlinsky/FBReader
 public SQLiteString(NativeMethods nativeMethods, Encoding encoding, String str)
 {
     _NativePtr = IntPtr.Zero;
     _ByteLength = 0;
     _Encoding = encoding;
     _StringValue  = str;
     _NativeMethods = nativeMethods;
 }
コード例 #21
0
		/// <summary>Navigation message.</summary>
		/// <remarks>The config structure will be marshaled: must be correctly disposed after use.</remarks>
        public Message(NativeMethods.TaskDialogMessages msg, int w, NativeMethods.TaskDialogConfig config) {
            MessageType = msg;
            wParam = w;

            _unsafeHandle = Marshal.AllocHGlobal(Marshal.SizeOf(config));
            Marshal.StructureToPtr(config, _unsafeHandle, false);
            lParam = (int)_unsafeHandle;
        }
コード例 #22
0
 static string GetBindString(NativeMethods.IInternetBindInfo bind, NativeMethods.BINDSTRING kind)
 {
     string[] result=GetBindStringList(bind,kind,1);
     if( result.Length==0 )
         return null;
     else
         return result[0];
 }
コード例 #23
0
		internal PluggableProtocolRequest(
            PluggableProtocolHandler handler,
            string url,
            NativeMethods.IInternetBindInfo bind,
            NativeMethods.PI_FLAGS startFlags )
		{
            m_Url=new Uri(url);

            int bindf;
            NativeMethods.BINDINFO bindinfo = new NativeMethods.BINDINFO();

            bindinfo.cbSize = Marshal.SizeOf( typeof(NativeMethods.STGMEDIUM) );
            bindinfo.cbSize = Marshal.SizeOf( typeof(NativeMethods.BINDINFO) );

//            string userAgent=GetBindString(
//                bind,
//                NativeMethods.BINDSTRING.BINDSTRING_USERAGENT );
//
//            System.Diagnostics.Trace.WriteLine(
//                "useragent: "+GetBindString(bind,NativeMethods.BINDSTRING.BINDSTRING_USERAGENT)+"\r\n"+
//                "url: "+GetBindString(bind,NativeMethods.BINDSTRING.BINDSTRING_URL)+"\r\n"+
//                "post cookie: "+GetBindString(bind,NativeMethods.BINDSTRING.BINDSTRING_POST_COOKIE)+"\r\n"+
//                "post MIME: "+GetBindString(bind,NativeMethods.BINDSTRING.BINDSTRING_POST_DATA_MIME) );



            bind.GetBindInfo( out bindf, ref bindinfo );

            switch( bindinfo.dwBindVerb )
            {
                case NativeMethods.BINDVERB.BINDVERB_GET: // GET
                    
                    m_Verb="GET";
                    m_VerbData=null;
                    break;

                case NativeMethods.BINDVERB.BINDVERB_POST:
                    
                    m_Verb="POST";
                    m_VerbData=ExtractVerbData(bindinfo);
                    
                    break;

                case NativeMethods.BINDVERB.BINDVERB_PUT:
                    
                    m_Verb="PUT";
                    m_VerbData=ExtractVerbData(bindinfo);

                    break;

                case NativeMethods.BINDVERB.BINDVERB_CUSTOM:
                    
                    m_Verb=Marshal.PtrToStringUni( bindinfo.szCustomVerb );
                    m_VerbData=ExtractVerbData(bindinfo);

                    break;
            }
        }
コード例 #24
0
 internal static void TransformLocalRectToScreen(HandleRef hwnd, ref NativeMethods.RECT rcWindowCoords)
 {
     int retval = MS.Internal.WindowsBase.NativeMethodsSetLastError.MapWindowPoints(hwnd , new HandleRef(null, IntPtr.Zero), ref rcWindowCoords, 2);
     int win32Err = Marshal.GetLastWin32Error();
     if(retval == 0 && win32Err != 0)
     {
         throw new System.ComponentModel.Win32Exception(win32Err);
     }
 }
 /// <summary>
 /// Sets attributes to control how visual styles are applied to a specified window.
 /// </summary>
 /// <param name="window">The window.</param>
 /// <param name="attr">The attributes to apply or disable.</param>
 /// <param name="enable">if set to <c>true</c> enable the attribute, otherwise disable it.</param>
 public static void SetWindowThemeAttribute(this IWin32Window window, NativeMethods.WindowThemeNonClientAttributes attr, bool enable = true)
 {
     NativeMethods.WTA_OPTIONS ops = new NativeMethods.WTA_OPTIONS();
     ops.Flags = attr;
     ops.Mask = enable ? (uint)attr : 0;
     try { NativeMethods.SetWindowThemeAttribute(window.Handle, NativeMethods.WindowThemeAttributeType.WTA_NONCLIENT, ref ops, Marshal.SizeOf(ops)); }
     catch (EntryPointNotFoundException) { }
     catch { throw; }
 }
コード例 #26
0
 private Guid GetPropertyPageGuid(NativeMethods.IPerPropertyBrowsing target, int dispid) {
     // check for a property page
     Guid guid;
     int hr = target.MapPropertyToPage(dispid, out guid);
     if (hr == NativeMethods.S_OK) {
         return guid;
     }
     return Guid.Empty;
 }
コード例 #27
0
 internal static extern void TaskDialog(
     IntPtr hwndParent,
     IntPtr hInstance,
     string pszWindowtitle,
     string pszMainInstruction,
     string pszContent,
     NativeMethods.TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons,
     string pszIcon,
     [In,Out] ref int pnButton);
コード例 #28
0
        internal HidDeviceAttributes(NativeMethods.HIDD_ATTRIBUTES attributes)
        {
            VendorId = attributes.VendorID;
            ProductId = attributes.ProductID;
            Version = attributes.VersionNumber;

            VendorHexId = "0x" + attributes.VendorID.ToString("X4");
            ProductHexId = "0x" + attributes.ProductID.ToString("X4");
        }
コード例 #29
0
        public unsafe void AsciiSearchForVariousPatternsWorks(
            long blockByteLength,
            string pattern,
            NativeMethods.SearchOptions searchOptions,
            int patternOccurrenceCount,
            int iterationCount)
        {
            Trace.WriteLine(
            string.Format(
              "Searching {0} time(s) for pattern \"{1}\" with {2} occurrence(s) in a memory block of {3:n0} bytes.",
              iterationCount, pattern, patternOccurrenceCount, blockByteLength));

              Assert.IsTrue(iterationCount >= 1);
              using (var textBlock = HeapAllocStatic.Alloc(blockByteLength)) {
            FillWithNonNulCharacters(textBlock);

            SetSearchMatches(textBlock, pattern, patternOccurrenceCount);

            using (var search = new AsciiStringSearchStrStr(pattern, searchOptions)) {
              var sw = Stopwatch.StartNew();
              var matchCount = PerformSearch(textBlock, search, iterationCount);
              sw.Stop();
              Assert.AreEqual(patternOccurrenceCount, matchCount);
              Trace.WriteLine(string.Format("  StrStr: Found {0:n0} occurrence(s) {1} times in {2}s ({3:n0} KB/s.)",
                                        matchCount, iterationCount, sw.Elapsed.TotalSeconds,
                                        ComputeThroughput(sw, blockByteLength, iterationCount)));
            }
            using (var search = new AsciiStringSearchBoyerMoore(pattern, searchOptions)) {
              var sw = Stopwatch.StartNew();
              var matchCount = PerformSearch(textBlock, search, iterationCount);
              sw.Stop();
              Assert.AreEqual(patternOccurrenceCount, matchCount);
              Trace.WriteLine(string.Format("  Boyer-Moore: Found {0:n0} occurrence(s) {1} times in {2} s ({3:n0} KB/s.)",
                                        matchCount, iterationCount, sw.Elapsed.TotalSeconds,
                                        ComputeThroughput(sw, blockByteLength, iterationCount)));
            }
            using (var search = new AsciiStringSearchBndm32(pattern, searchOptions)) {
              var sw = Stopwatch.StartNew();
              var matchCount = PerformSearch(textBlock, search, iterationCount);
              sw.Stop();
              Assert.AreEqual(patternOccurrenceCount, matchCount);
              Trace.WriteLine(string.Format("  BNDM-32: Found {0:n0} occurrence(s) {1} times in {2} s ({3:n0} KB/s.)",
                                        matchCount, iterationCount, sw.Elapsed.TotalSeconds,
                                        ComputeThroughput(sw, blockByteLength, iterationCount)));
            }
            using (var search = new AsciiStringSearchBndm64(pattern, searchOptions)) {
              var sw = Stopwatch.StartNew();
              var matchCount = PerformSearch(textBlock, search, iterationCount);
              sw.Stop();
              Assert.AreEqual(patternOccurrenceCount, matchCount);
              Trace.WriteLine(string.Format("  BNDM-64: Found {0:n0} occurrence(s) {1} times in {2} s ({3:n0} KB/s.)",
                                        matchCount, iterationCount, sw.Elapsed.TotalSeconds,
                                        ComputeThroughput(sw, blockByteLength, iterationCount)));
            }
              }
        }
コード例 #30
0
		private static IntPtr SetHook(NativeMethods.LowLevelMouseProc proc)
		{
			using (Process curProcess = Process.GetCurrentProcess())
			{
				using (ProcessModule curModule = curProcess.MainModule)
				{
					return NativeMethods.SetWindowsHookEx(NativeMethods.WH_MOUSE_LL, proc, NativeMethods.GetModuleHandle(curModule.ModuleName), 0);
				}
			}
		}
コード例 #31
0
 /// <summary>
 /// <para> returns the language the steam client is running in, you probably want ISteamApps::GetCurrentGameLanguage instead, this is for very special usage cases</para>
 /// </summary>
 public static string GetSteamUILanguage()
 {
     InteropHelp.TestIfAvailableGameServer();
     return(InteropHelp.PtrToStringUTF8(NativeMethods.ISteamUtils_GetSteamUILanguage(CSteamGameServerAPIContext.GetSteamUtils())));
 }
コード例 #32
0
 /// <summary>
 /// <para> ask SteamUI to create and render its OpenVR dashboard</para>
 /// </summary>
 public static void StartVRDashboard()
 {
     InteropHelp.TestIfAvailableGameServer();
     NativeMethods.ISteamUtils_StartVRDashboard(CSteamGameServerAPIContext.GetSteamUtils());
 }
コード例 #33
0
 public static bool GetAPICallResult(SteamAPICall_t hSteamAPICall, IntPtr pCallback, int cubCallback, int iCallbackExpected, out bool pbFailed)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_GetAPICallResult(CSteamGameServerAPIContext.GetSteamUtils(), hSteamAPICall, pCallback, cubCallback, iCallbackExpected, out pbFailed));
 }
コード例 #34
0
 /// <summary>
 /// <para> returns the number of IPC calls made since the last time this function was called</para>
 /// <para> Used for perf debugging so you can understand how many IPC calls your game makes per frame</para>
 /// <para> Every IPC call is at minimum a thread context switch if not a process one so you want to rate</para>
 /// <para> control how often you do them.</para>
 /// </summary>
 public static uint GetIPCCallCount()
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_GetIPCCallCount(CSteamGameServerAPIContext.GetSteamUtils()));
 }
コード例 #35
0
 public static ESNetSocketConnectionType GetSocketConnectionType(SNetSocket_t hSocket)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamGameServerNetworking_GetSocketConnectionType(hSocket));
 }
コード例 #36
0
 /// <summary>
 /// <para> API warning handling</para>
 /// <para> 'int' is the severity; 0 for msg, 1 for warning</para>
 /// <para> 'const char *' is the text of the message</para>
 /// <para> callbacks will occur directly after the API function is called that generated the warning or message</para>
 /// </summary>
 public static void SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction)
 {
     InteropHelp.TestIfAvailableGameServer();
     NativeMethods.ISteamUtils_SetWarningMessageHook(CSteamGameServerAPIContext.GetSteamUtils(), pFunction);
 }
コード例 #37
0
 /// <summary>
 /// <para> Normally this call is unneeded if your game has a constantly running frame loop that calls the</para>
 /// <para> D3D Present API, or OGL SwapBuffers API every frame.</para>
 /// <para> However, if you have a game that only refreshes the screen on an event driven basis then that can break</para>
 /// <para> the overlay, as it uses your Present/SwapBuffers calls to drive it's internal frame loop and it may also</para>
 /// <para> need to Present() to the screen any time an even needing a notification happens or when the overlay is</para>
 /// <para> brought up over the game by a user.  You can use this API to ask the overlay if it currently need a present</para>
 /// <para> in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you</para>
 /// <para> refresh the screen with Present or SwapBuffers to allow the overlay to do it's work.</para>
 /// </summary>
 public static bool BOverlayNeedsPresent()
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_BOverlayNeedsPresent(CSteamGameServerAPIContext.GetSteamUtils()));
 }
コード例 #38
0
 public static int GetMaxPacketSize(SNetSocket_t hSocket)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamGameServerNetworking_GetMaxPacketSize(hSocket));
 }
コード例 #39
0
 /// <summary>
 /// <para> returns true if Steam &amp; the Steam Overlay are running in Big Picture mode</para>
 /// <para> Games much be launched through the Steam client to enable the Big Picture overlay. During development,</para>
 /// <para> a game can be added as a non-steam game to the developers library to test this feature</para>
 /// </summary>
 public static bool IsSteamInBigPictureMode()
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_IsSteamInBigPictureMode(CSteamGameServerAPIContext.GetSteamUtils()));
 }
コード例 #40
0
 public static uint GetSecondsSinceComputerActive()
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_GetSecondsSinceComputerActive(CSteamGameServerAPIContext.GetSteamUtils()));
 }
コード例 #41
0
 /// <summary>
 /// <para> Return what we believe your current ipv6 connectivity to "the internet" is on the specified protocol.</para>
 /// <para> This does NOT tell you if the Steam client is currently connected to Steam via ipv6.</para>
 /// </summary>
 public static ESteamIPv6ConnectivityState GetIPv6ConnectivityState(ESteamIPv6ConnectivityProtocol eProtocol)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_GetIPv6ConnectivityState(CSteamGameServerAPIContext.GetSteamUtils(), eProtocol));
 }
コード例 #42
0
 /// <summary>
 /// <para> Initializes text filtering, loading dictionaries for the language the game is running in.</para>
 /// <para>   unFilterOptions are reserved for future use and should be set to 0</para>
 /// <para> Returns false if filtering is unavailable for the game's language, in which case FilterText() will act as a passthrough.</para>
 /// <para> Users can customize the text filter behavior in their Steam Account preferences:</para>
 /// <para> https://store.steampowered.com/account/preferences#CommunityContentPreferences</para>
 /// </summary>
 public static bool InitFilterText(uint unFilterOptions = 0)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_InitFilterText(CSteamGameServerAPIContext.GetSteamUtils(), unFilterOptions));
 }
コード例 #43
0
 /// <summary>
 /// <para> Sets the position where the overlay instance for the currently calling game should show notifications.</para>
 /// <para> This position is per-game and if this function is called from outside of a game context it will do nothing.</para>
 /// </summary>
 public static void SetOverlayNotificationPosition(ENotificationPosition eNotificationPosition)
 {
     InteropHelp.TestIfAvailableGameServer();
     NativeMethods.ISteamUtils_SetOverlayNotificationPosition(CSteamGameServerAPIContext.GetSteamUtils(), eNotificationPosition);
 }
コード例 #44
0
 public static bool IsDataAvailableOnSocket(SNetSocket_t hSocket, out uint pcubMsgSize)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamGameServerNetworking_IsDataAvailableOnSocket(hSocket, out pcubMsgSize));
 }
コード例 #45
0
 /// <summary>
 /// <para> Returns previously entered text &amp; length</para>
 /// </summary>
 public static uint GetEnteredGamepadTextLength()
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_GetEnteredGamepadTextLength(CSteamGameServerAPIContext.GetSteamUtils()));
 }
コード例 #46
0
 public static ESteamAPICallFailure GetAPICallFailureReason(SteamAPICall_t hSteamAPICall)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_GetAPICallFailureReason(CSteamGameServerAPIContext.GetSteamUtils(), hSteamAPICall));
 }
コード例 #47
0
 /// <summary>Clears the unused memory.</summary>
 public static void ClearUnusedMemory()
 {
     NativeMethods.ClearUnusedMemory();
 }
コード例 #48
0
 /// <summary>
 /// <para> Sets the inset of the overlay notification from the corner specified by SetOverlayNotificationPosition.</para>
 /// </summary>
 public static void SetOverlayNotificationInset(int nHorizontalInset, int nVerticalInset)
 {
     InteropHelp.TestIfAvailableGameServer();
     NativeMethods.ISteamUtils_SetOverlayNotificationInset(CSteamGameServerAPIContext.GetSteamUtils(), nHorizontalInset, nVerticalInset);
 }
コード例 #49
0
 public static bool GetSocketInfo(SNetSocket_t hSocket, out CSteamID pSteamIDRemote, out int peSocketStatus, out uint punIPRemote, out ushort punPortRemote)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamGameServerNetworking_GetSocketInfo(hSocket, out pSteamIDRemote, out peSocketStatus, out punIPRemote, out punPortRemote));
 }
コード例 #50
0
 /// <summary>Shows the windows error.</summary>
 /// <param name="errorCode">The error code.</param>
 public static void ShowWindowsError(int errorCode)
 {
     NativeMethods.ShowError(errorCode);
 }
コード例 #51
0
 public static bool GetP2PSessionState(CSteamID steamIDRemote, out P2PSessionState_t pConnectionState)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamGameServerNetworking_GetP2PSessionState(steamIDRemote, out pConnectionState));
 }
コード例 #52
0
 /// <summary>
 /// Turns the monitor off.
 /// </summary>
 public static void TurnMonitorOff()
 {
     NativeMethods.TurnMonitorOff();
 }
コード例 #53
0
 public static bool AcceptP2PSessionWithUser(CSteamID steamIDRemote)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamGameServerNetworking_AcceptP2PSessionWithUser(steamIDRemote));
 }
コード例 #54
0
 public static bool GetStartup(string appName)
 {
     return NativeMethods.GetStartup(appName);
 }
コード例 #55
0
 private static int s_bitDepth; // = 0;
 private static int _GetBitDepth()
 {
     if (s_bitDepth == 0)
     {
         using (SafeDC dc = SafeDC.GetDesktop())
         {
             s_bitDepth = NativeMethods.GetDeviceCaps(dc, DeviceCap.BITSPIXEL) * NativeMethods.GetDeviceCaps(dc, DeviceCap.PLANES);
         }
     }
     return(s_bitDepth);
 }
コード例 #56
0
 /// <summary>
 /// <para> Returns true if the HMD content will be streamed via Steam Remote Play</para>
 /// </summary>
 public static bool IsVRHeadsetStreamingEnabled()
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_IsVRHeadsetStreamingEnabled(CSteamGameServerAPIContext.GetSteamUtils()));
 }
コード例 #57
0
        public static IntPtr GenerateHICON(ImageSource image, Size dimensions)
        {
            if (image == null)
            {
                return(IntPtr.Zero);
            }

            // If we're getting this from a ".ico" resource, then it comes through as a BitmapFrame.
            // We can use leverage this as a shortcut to get the right 16x16 representation
            // because DrawImage doesn't do that for us.
            var bf = image as BitmapFrame;

            if (bf != null)
            {
                bf = GetBestMatch(bf.Decoder.Frames, (int)dimensions.Width, (int)dimensions.Height);
            }
            else
            {
                // Constrain the dimensions based on the aspect ratio.
                var drawingDimensions = new Rect(0, 0, dimensions.Width, dimensions.Height);

                // There's no reason to assume that the requested image dimensions are square.
                double renderRatio = dimensions.Width / dimensions.Height;
                double aspectRatio = image.Width / image.Height;

                // If it's smaller than the requested size, then place it in the middle and pad the image.
                if (image.Width <= dimensions.Width && image.Height <= dimensions.Height)
                {
                    drawingDimensions = new Rect((dimensions.Width - image.Width) / 2, (dimensions.Height - image.Height) / 2, image.Width, image.Height);
                }
                else if (renderRatio > aspectRatio)
                {
                    double scaledRenderWidth = (image.Width / image.Height) * dimensions.Width;
                    drawingDimensions = new Rect((dimensions.Width - scaledRenderWidth) / 2, 0, scaledRenderWidth, dimensions.Height);
                }
                else if (renderRatio < aspectRatio)
                {
                    double scaledRenderHeight = (image.Height / image.Width) * dimensions.Height;
                    drawingDimensions = new Rect(0, (dimensions.Height - scaledRenderHeight) / 2, dimensions.Width, scaledRenderHeight);
                }

                var            dv = new DrawingVisual();
                DrawingContext dc = dv.RenderOpen();
                dc.DrawImage(image, drawingDimensions);
                dc.Close();

                var bmp = new RenderTargetBitmap((int)dimensions.Width, (int)dimensions.Height, 96, 96, PixelFormats.Pbgra32);
                bmp.Render(dv);
                bf = BitmapFrame.Create(bmp);
            }

            // Using GDI+ to convert to an HICON.
            // I'd rather not duplicate their code.
            using (MemoryStream memstm = new MemoryStream())
            {
                BitmapEncoder enc = new PngBitmapEncoder();
                enc.Frames.Add(bf);
                enc.Save(memstm);

                using (var istm = new ManagedIStream(memstm))
                {
                    // We are not bubbling out GDI+ errors when creating the native image fails.
                    IntPtr bitmap = IntPtr.Zero;
                    try
                    {
                        Status gpStatus = NativeMethods.GdipCreateBitmapFromStream(istm, out bitmap);
                        if (Status.Ok != gpStatus)
                        {
                            return(IntPtr.Zero);
                        }

                        IntPtr hicon;
                        gpStatus = NativeMethods.GdipCreateHICONFromBitmap(bitmap, out hicon);
                        if (Status.Ok != gpStatus)
                        {
                            return(IntPtr.Zero);
                        }

                        // Caller is responsible for freeing this.
                        return(hicon);
                    }
                    finally
                    {
                        Utility.SafeDisposeImage(ref bitmap);
                    }
                }
            }
        }
コード例 #58
0
 /// <summary>
 /// <para> API asynchronous call results</para>
 /// <para> can be used directly, but more commonly used via the callback dispatch API (see steam_api.h)</para>
 /// </summary>
 public static bool IsAPICallCompleted(SteamAPICall_t hSteamAPICall, out bool pbFailed)
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_IsAPICallCompleted(CSteamGameServerAPIContext.GetSteamUtils(), hSteamAPICall, out pbFailed));
 }
コード例 #59
0
 /// <summary>
 /// <para> Set whether the HMD content will be streamed via Steam Remote Play</para>
 /// <para> If this is set to true, then the scene in the HMD headset will be streamed, and remote input will not be allowed.</para>
 /// <para> If this is set to false, then the application window will be streamed instead, and remote input will be allowed.</para>
 /// <para> The default is true unless "VRHeadsetStreaming" "0" is in the extended appinfo for a game.</para>
 /// <para> (this is useful for games that have asymmetric multiplayer gameplay)</para>
 /// </summary>
 public static void SetVRHeadsetStreamingEnabled(bool bEnabled)
 {
     InteropHelp.TestIfAvailableGameServer();
     NativeMethods.ISteamUtils_SetVRHeadsetStreamingEnabled(CSteamGameServerAPIContext.GetSteamUtils(), bEnabled);
 }
コード例 #60
0
 /// <summary>
 /// <para> Returns whether this steam client is a Steam China specific client, vs the global client.</para>
 /// </summary>
 public static bool IsSteamChinaLauncher()
 {
     InteropHelp.TestIfAvailableGameServer();
     return(NativeMethods.ISteamUtils_IsSteamChinaLauncher(CSteamGameServerAPIContext.GetSteamUtils()));
 }