Added cap query support example.

This commit is contained in:
soukoku
2014-04-20 22:24:05 -04:00
parent a766370930
commit 31f77edb40
11 changed files with 76 additions and 44 deletions

View File

@@ -3,9 +3,6 @@ using System.Collections.Generic;
namespace NTwain.Internals
{
/// <summary>
/// Internal interface for state management.
/// </summary>
interface ITwainSessionInternal : ITwainSession
{
/// <summary>

View File

@@ -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
}

View File

@@ -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);
}
}
}