mirror of
https://github.com/soukoku/ntwain.git
synced 2026-01-02 20:42:17 +08:00
Added cap query support example.
This commit is contained in:
@@ -3,9 +3,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace NTwain.Internals
|
||||
{
|
||||
/// <summary>
|
||||
/// Internal interface for state management.
|
||||
/// </summary>
|
||||
interface ITwainSessionInternal : ITwainSession
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
namespace NTwain.Internals
|
||||
{
|
||||
static class NativeMethods
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
static class UnsafeNativeMethods
|
||||
{
|
||||
// should be unsafe native methods?
|
||||
|
||||
#region mem stuff for twain 1.x
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalAlloc")]
|
||||
public static extern IntPtr WinGlobalAlloc(uint uFlags, UIntPtr dwBytes);
|
||||
internal static extern IntPtr WinGlobalAlloc(uint uFlags, UIntPtr dwBytes);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalFree")]
|
||||
public static extern IntPtr WinGlobalFree(IntPtr hMem);
|
||||
internal static extern IntPtr WinGlobalFree(IntPtr hMem);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalLock")]
|
||||
public static extern IntPtr WinGlobalLock(IntPtr handle);
|
||||
internal static extern IntPtr WinGlobalLock(IntPtr handle);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalUnlock")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool WinGlobalUnlock(IntPtr handle);
|
||||
internal static extern bool WinGlobalUnlock(IntPtr handle);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace NTwain
|
||||
{
|
||||
public IntPtr Allocate(uint size)
|
||||
{
|
||||
IntPtr retVal = NativeMethods.WinGlobalAlloc(0x0040, new UIntPtr(size));
|
||||
IntPtr retVal = UnsafeNativeMethods.WinGlobalAlloc(0x0040, new UIntPtr(size));
|
||||
|
||||
if (retVal == IntPtr.Zero)
|
||||
{
|
||||
@@ -24,17 +24,17 @@ namespace NTwain
|
||||
|
||||
public void Free(IntPtr handle)
|
||||
{
|
||||
NativeMethods.WinGlobalFree(handle);
|
||||
UnsafeNativeMethods.WinGlobalFree(handle);
|
||||
}
|
||||
|
||||
public IntPtr Lock(IntPtr handle)
|
||||
{
|
||||
return NativeMethods.WinGlobalLock(handle);
|
||||
return UnsafeNativeMethods.WinGlobalLock(handle);
|
||||
}
|
||||
|
||||
public void Unlock(IntPtr handle)
|
||||
{
|
||||
NativeMethods.WinGlobalUnlock(handle);
|
||||
UnsafeNativeMethods.WinGlobalUnlock(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user