Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than urlmon, prefix the name with the module name and a period.
public static extern void CopyMemory(IntPtr dest, IntPtr src, uint count);
VB Signature:
Public Declare Auto Sub CopyMemory lib "kernel32.dll" Alias "CopyMemory"(destination As IntPtr, source As IntPtr, length As UInteger)
<DllImport("kernel32.dll", SetLastError:= True, EntryPoint:= "CopyMemory")>
Public Shared Sub CopyMemory(destination As IntPtr, source As IntPtr, length As UInteger)
End Sub
Public Declare Auto Sub CopyMemory lib "kernel32.dll" Alias "CopyMemory"(destination As IntPtr, source As IntPtr, length As UInteger)
Public Sub Main(ParamArray args As String())
Dim source As Byte() = File.ReadAllBytes("C:\Windows\explorer.exe"),
destination(source.GetUpperBound(0)) As Byte,
length As UInteger = CUInt(source.Length),
sourcePtr As IntPtr = Marshal.UnsafeAddrOfPinnedArrayElement(source, 0),
targetPtr As IntPtr = Marshal.UnsafeAddrOfPinnedArrayElement(target, 0)
sourcePtr As IntPtr = Marshal.UnsafeAddrOfPinnedElement(source, 0),
targetPtr As IntPtr = Marshal.UnsafeAddrOfPinnedElement(target, 0)
Restart:
Dim sw As Stopwatch = Stopwatch.StartNew()
CopyMemory(targetPtr, sourcePtr, length)
sw.Stop()
Console.WriteLine("Total time to copy {0:N0} bytes = {1}", new TimeSpan(sw.ElapsedTicks))
Using sha = New System.Security.Cryptography.SHA512Managed
Dim sourceChecksum = sha.ComputeHash(source),
destinationCheksum = sha.ComputeHash(destination),
isEquals = True
Dim sourceChecksum = sha.ComputeHash(source), destinationCheksum = sha.ComputeHash(destination), isEquals = True
For i = 0 To sourceChecksum.GetUpperBound(0)
If sourceChecksum(i) <> destinationChecksum(i) Then
Console.WriteLine("The copy memory is bad, some of data are not copied..")
IsEquals = False
Exit For
End If
Next i
If isEquals Then Console.WriteLine("The copy memory is perfectly copy all bytes.")
End Using
Console.ReadKey().Key = ConsoleKeys.R Then
Main(args)
Goto Restart
End If
sw = Nothing
Erase source, destination
End Sub
3/16/2007 7:31:57 AM - anfortas.geo@yahoo.com-216.204.61.86
The SetLastError API
1/26/2016 3:27:33 AM - -124.148.167.58
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 4:00:13 AM - Damon Carr-72.43.165.29
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).