mirror of
https://github.com/soukoku/ntwain.git
synced 2025-10-08 00:14:38 +08:00
Fixed some comments and types.
This commit is contained in:
@@ -9,8 +9,10 @@ namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides methods for managing memory on data exchanged with twain sources.
|
||||
/// This should only be used after the DSM has been opened in <see cref="TwainSession"/>
|
||||
/// via <see cref="TwainSession.OpenManager"/>.
|
||||
/// </summary>
|
||||
class MemoryManager
|
||||
public class MemoryManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the global <see cref="MemoryManager"/> instance.
|
||||
@@ -30,6 +32,11 @@ namespace NTwain
|
||||
|
||||
TWEntryPoint _twain2Entry;
|
||||
|
||||
/// <summary>
|
||||
/// Function to allocate memory. Calls to this must be coupled with <see cref="MemFree"/> later.
|
||||
/// </summary>
|
||||
/// <param name="size">The size in bytes.</param>
|
||||
/// <returns>Handle to the allocated memory.</returns>
|
||||
public IntPtr MemAllocate(uint size)
|
||||
{
|
||||
if (_twain2Entry != null && _twain2Entry.AllocateFunction != null)
|
||||
@@ -42,6 +49,11 @@ namespace NTwain
|
||||
return GlobalAlloc(0x0040, new UIntPtr(size));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to free memory.
|
||||
/// </summary>
|
||||
/// <param name="handle">The handle from <see cref="MemAllocate"/>.</param>
|
||||
public void MemFree(IntPtr handle)
|
||||
{
|
||||
if (_twain2Entry != null && _twain2Entry.FreeFunction != null)
|
||||
@@ -53,6 +65,12 @@ namespace NTwain
|
||||
GlobalFree(handle);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to lock some memory. Calls to this must be coupled with <see cref="MemUnlock"/> later.
|
||||
/// </summary>
|
||||
/// <param name="handle">The handle to allocated memory.</param>
|
||||
/// <returns>Handle to the lock.</returns>
|
||||
public IntPtr MemLock(IntPtr handle)
|
||||
{
|
||||
if (_twain2Entry != null && _twain2Entry.LockFunction != null)
|
||||
@@ -64,6 +82,11 @@ namespace NTwain
|
||||
return GlobalLock(handle);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to unlock a previously locked memory region.
|
||||
/// </summary>
|
||||
/// <param name="handle">The handle from <see cref="MemLock"/>.</param>
|
||||
public void MemUnlock(IntPtr handle)
|
||||
{
|
||||
if (_twain2Entry != null && _twain2Entry.UnlockFunction != null)
|
||||
@@ -82,14 +105,14 @@ namespace NTwain
|
||||
static extern IntPtr GlobalAlloc(uint uFlags, UIntPtr dwBytes);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
|
||||
public static extern IntPtr GlobalFree(IntPtr hMem);
|
||||
static extern IntPtr GlobalFree(IntPtr hMem);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
|
||||
public static extern IntPtr GlobalLock(IntPtr handle);
|
||||
static extern IntPtr GlobalLock(IntPtr handle);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool GlobalUnlock(IntPtr handle);
|
||||
static extern bool GlobalUnlock(IntPtr handle);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
Reference in New Issue
Block a user