本文整理汇总了C#中UIntPtr类的典型用法代码示例。如果您正苦于以下问题:C# UIntPtr类的具体用法?C# UIntPtr怎么用?C# UIntPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UIntPtr类属于命名空间,在下文中一共展示了UIntPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WithRefsWithReturn
public object WithRefsWithReturn(
ref string param1,
ref int param2,
ref short param3,
ref long param4,
ref uint param5,
ref ushort param6,
ref ulong param7,
ref bool param8,
ref double param9,
ref decimal param10,
ref int? param11,
ref object param12,
ref char param13,
ref DateTime param14,
ref Single param15,
ref IntPtr param16,
ref UInt16 param17,
ref UInt32 param18,
ref UInt64 param19,
ref UIntPtr param20
)
{
throw new Exception("Foo");
}
示例2: ReadProcessMemory
static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
[Out] byte[] lpBuffer,
UIntPtr nSize,
[Out] out UIntPtr lpNumberOfBytesRead
);
示例3: TestCtor_VoidPointer_ToPointer
public static unsafe void TestCtor_VoidPointer_ToPointer()
{
void* pv = new UIntPtr(42).ToPointer();
VerifyPointer(new UIntPtr(pv), 42);
VerifyPointer((UIntPtr)pv, 42);
}
示例4: PosTest1
public bool PosTest1()
{
bool retVal = true;
const string c_TEST_ID = "P001";
const string c_TEST_DESC = "PosTest1: random valid UInt64 value";
string errorDesc;
UIntPtr actualUIntPtr;
bool actualResult;
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
try
{
UInt64 ui = this.GetValidUInt64();
actualUIntPtr = new UIntPtr(ui);
actualResult = actualUIntPtr.ToUInt64() == ui;
if (!actualResult)
{
errorDesc = "Actual UIntPtr value is not " + ui + " as expected: Actual(" + actualUIntPtr + ")";
TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
retVal = false;
}
}
catch (Exception e)
{
errorDesc = "Unexpected exception: " + e;
TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc);
retVal = false;
}
return retVal;
}
示例5: WorkOnInstanceAndLocal
private void WorkOnInstanceAndLocal()
{
UIntPtr localInt;
int i, j;
for ( i = 0; i < 100; i++ )
{
int index = randomNumGen.Next(0, ValueArraySize);
instanceInt_1 = ValueArray[index];
Thread.Sleep(index);
localInt = instanceInt_1;
for ( j = 0; j < ValueArraySize; j++ )
if ( ValueArray[j] == localInt )
break;
if (j == ValueArraySize )
throw new Exception("WorkOnInstanceAndLocal: Atomicity of Read/Write violated - " + localInt);
}
UIntPtr localInt_1;
localInt_1 = (UIntPtr)(1 + 1);
if((UInt32)localInt_1 != 2)
throw new Exception("Loc_7453fg! Major Error here");
localInt_1 = (UIntPtr)(UInt32.MaxValue + UInt32.MinValue);
if((UInt32)localInt_1 != UInt32.MaxValue)
throw new Exception("Loc_2375dsfg! Major Error here");
localInt_1 = (UIntPtr)(Int16.MaxValue * 2);
if((UInt32)localInt_1 != 65534)
throw new Exception("Loc_3975sg! Major Error here, " + localInt_1);
localInt_1 = (UIntPtr)UInt32.MaxValue;
if(localInt_1.GetHashCode() != 2147483647)
throw new Exception("Loc_5086dsfg! Major Error here, " + localInt_1.GetHashCode());
if(localInt_1.ToString() != "4294967295")
throw new Exception("Loc_24967esdfg! Major Error here, " + localInt_1.ToString());
}
示例6: PosTest1
public bool PosTest1()
{
bool retVal = true;
const string c_TEST_ID = "P001";
const string c_TEST_DESC = "PosTest1: UIntPtr.Zero vs UIntPtr(0)";
string errorDesc;
UIntPtr srcUIntPtr, expUIntPtr;
bool actualResult;
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
try
{
expUIntPtr = new UIntPtr();
srcUIntPtr = UIntPtr.Zero;
actualResult = srcUIntPtr.Equals(expUIntPtr);
if (!actualResult)
{
errorDesc = "Source UIntPtr value does not equal" + expUIntPtr + " as expected: Actual(" + srcUIntPtr + ")";
TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
retVal = false;
}
}
catch (Exception e)
{
errorDesc = "Unexpected exception: " + e;
TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc);
retVal = false;
}
return retVal;
}
示例7: runTest
public virtual bool runTest()
{
Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
int iCountErrors = 0;
int iCountTestcases = 0;
String strLoc = "Loc_000oo";
UIntPtr ip1;
UIntPtr ip2;
UInt32 iValue;
try {
strLoc = "Loc_743wg";
iValue = 16;
ip1 = new UIntPtr(iValue);
ip2 = new UIntPtr(iValue);
iCountTestcases++;
if(!ip1.Equals(ip2)){
iCountErrors++;
Console.WriteLine("Err_865sg! Wrong value returned");
}
strLoc = "Loc_9047tdsg";
iValue = 16;
ip1 = new UIntPtr(iValue);
ip2 = new UIntPtr(iValue*2);
iCountTestcases++;
if(ip1.Equals(ip2)){
iCountErrors++;
Console.WriteLine("Err_9765sgf! Wrong value returned");
}
strLoc = "Loc_98736zdg";
iValue = 16;
ip1 = new UIntPtr(iValue);
iCountTestcases++;
if(ip1.Equals(iValue)){
iCountErrors++;
Console.WriteLine("Err_9756gf! Wrong value returned");
}
strLoc = "Loc_98736zdg";
iValue = 16;
ip1 = new UIntPtr(iValue);
iCountTestcases++;
if(ip1.Equals(null)){
iCountErrors++;
Console.WriteLine("Err_973sdg! Wrong value returned");
}
} catch (Exception exc_general ) {
++iCountErrors;
Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general);
}
if ( iCountErrors == 0 )
{
Console.Error.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
return true;
}
else
{
Console.Error.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
return false;
}
}
示例8: VirtualAlloc
public static IntPtr VirtualAlloc(
SafeHandle baseAddress,
UIntPtr size,
int allocationType,
int protection)
{
return Interop.Kernel32.VirtualAlloc(baseAddress, size, allocationType, protection);
}
示例9: MapViewOfFile
public static SafeMemoryMappedViewHandle MapViewOfFile(
SafeMemoryMappedFileHandle hFileMappingObject,
int desiredAccess,
long fileOffset,
UIntPtr numberOfBytesToMap)
{
return Interop.mincore.MapViewOfFileFromApp(hFileMappingObject, desiredAccess, fileOffset, numberOfBytesToMap);
}
示例10: Outer
private static void Outer()
{
float f = 42.0f;
double d = 43.0;
IntPtr ptr = new IntPtr(0x42424242);
UIntPtr uptr = new UIntPtr(0x43434343);
Middle();
}
示例11: VirtualAlloc
public static IntPtr VirtualAlloc(
SafeHandle baseAddress,
UIntPtr size,
int allocationType,
int protection)
{
return Interop.mincore.VirtualAllocFromApp(baseAddress, size, allocationType, protection);
}
示例12: MemAlloc
internal static IntPtr MemAlloc(UIntPtr sizeInBytes, uint flags)
{
IntPtr allocatedMemory = Interop.mincore.HeapAlloc(Interop.mincore.GetProcessHeap(), flags, sizeInBytes);
if (allocatedMemory == IntPtr.Zero)
{
throw new OutOfMemoryException();
}
return allocatedMemory;
}
示例13: MemAlloc
internal static IntPtr MemAlloc(UIntPtr sizeInBytes)
{
IntPtr allocatedMemory = Interop.Sys.MemAlloc(sizeInBytes);
if (allocatedMemory == IntPtr.Zero)
{
throw new OutOfMemoryException();
}
return allocatedMemory;
}
示例14: MemReAlloc
internal static IntPtr MemReAlloc(IntPtr ptr, UIntPtr oldSize, UIntPtr newSize, uint flags)
{
IntPtr allocatedMemory = Interop.mincore.HeapReAlloc(Interop.mincore.GetProcessHeap(), flags, ptr, newSize);
if (allocatedMemory == IntPtr.Zero)
{
throw new OutOfMemoryException();
}
return allocatedMemory;
}
示例15: MemReAlloc
internal unsafe static IntPtr MemReAlloc(IntPtr ptr, UIntPtr newSize)
{
IntPtr allocatedMemory = Interop.Sys.MemReAlloc(ptr, newSize);
if (allocatedMemory == IntPtr.Zero)
{
throw new OutOfMemoryException();
}
return allocatedMemory;
}