本文整理汇总了C#中NativeMethods类的典型用法代码示例。如果您正苦于以下问题:C# NativeMethods类的具体用法?C# NativeMethods怎么用?C# NativeMethods使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NativeMethods类属于命名空间,在下文中一共展示了NativeMethods类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Send
/// <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;
}
}
开发者ID:Andrea,项目名称:duality-withsvn-history,代码行数:34,代码来源:RecycleBin.cs
示例2: HookCallback
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);
}
开发者ID:jeremistadler,项目名称:elephant-memory,代码行数:25,代码来源:KeyboardHook.cs
示例3: BackupStreamInfo
/// <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;
}
开发者ID:Sicos1977,项目名称:AlphaFS,代码行数:12,代码来源:BackupStreamInfo.cs
示例4: PluggableProtocolResponse
internal PluggableProtocolResponse(
PluggableProtocolHandler handler,
NativeMethods.IInternetProtocolSink sink )
{
this.handler=handler;
this.m_Sink=sink;
}
开发者ID:Mofsy,项目名称:jinxbot,代码行数:7,代码来源:PluggableProtocolResponse.cs
示例5: ThrowWhenFailed
private static void ThrowWhenFailed(NativeMethods.ExecutionStates previousState)
{
if (previousState == 0)
{
throw new Exception("Failed to suppress/restore system power management.");
}
}
开发者ID:bkoelman,项目名称:DogAgilityCompetitionManagement,代码行数:7,代码来源:SystemPowerManagementProvider.cs
示例6: Compile
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();
}
开发者ID:evlinsky,项目名称:FBReader,代码行数:31,代码来源:SQLiteStatement.cs
示例7: GetAttributes
/// <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;
}
开发者ID:glocklueng,项目名称:stm32f4_HID_Aplication,代码行数:38,代码来源:Hid.cs
示例8: ControlCallback
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;
}
开发者ID:chutinhha,项目名称:aiaintranet,代码行数:34,代码来源:TraceProvider.cs
示例9: GetBuilderGuidString
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;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:Com2IProvidePropertyBuilderHandler.cs
示例10: CreateSearchAlgo
public static AsciiStringSearchAlgorithm CreateSearchAlgo(string pattern, NativeMethods.SearchOptions searchOptions)
{
if (pattern.Length <= 64)
return new AsciiStringSearchBndm64(pattern, searchOptions);
else
return new AsciiStringSearchBoyerMoore(pattern, searchOptions);
}
开发者ID:kleopatra999,项目名称:vs-chromium,代码行数:7,代码来源:AsciiFileContents.cs
示例11: DrawText
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;
}
开发者ID:tablesmit,项目名称:task-scheduler-managed-wrapper,代码行数:7,代码来源:VisualStylesRendererExtension.cs
示例12: CategoryEntry
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];
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:CategoryEntry.cs
示例13: IconHandleInfo
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);
}
开发者ID:yuan39,项目名称:screencast-capture,代码行数:7,代码来源:IconHandleInfo.cs
示例14: WinPosition
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;
}
开发者ID:RichardRanft,项目名称:DNT-Torque3D-V1.1,代码行数:7,代码来源:NativeMethods.cs
示例15: Message
/// <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;
}
开发者ID:ccasalicchio,项目名称:Cassini-Original-Project,代码行数:9,代码来源:Message.cs
示例16: BluetoothDevice
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;
}
开发者ID:nydehi,项目名称:wiidevicelibrary,代码行数:8,代码来源:BluetoothDevice.cs
示例17: GetBindString
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];
}
开发者ID:Mofsy,项目名称:jinxbot,代码行数:8,代码来源:PluggableProtocolRequest.cs
示例18: SQLiteString
public SQLiteString(NativeMethods nativeMethods, Encoding encoding, String str)
{
_NativePtr = IntPtr.Zero;
_ByteLength = 0;
_Encoding = encoding;
_StringValue = str;
_NativeMethods = nativeMethods;
}
开发者ID:evlinsky,项目名称:FBReader,代码行数:8,代码来源:SQLiteString.cs
示例19: RasCompressionOptions
/// <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);
}
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:12,代码来源:RasCompressionOptions.cs
示例20: GetDerivedOptionFlags
internal override NativeMethods.FOS GetDerivedOptionFlags(NativeMethods.FOS flags)
{
if (multiselect)
flags |= NativeMethods.FOS.FOS_ALLOWMULTISELECT;
// TODO: other flags
return flags;
}
开发者ID:ssickles,项目名称:archive,代码行数:8,代码来源:CommonOpenFileDialog.cs
注:本文中的NativeMethods类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论