Click here to Skip to main content
15,920,602 members
Home / Discussions / C#
   

C#

 
AnswerRe: CS1929 Pin
OriginalGriff17-Mar-21 11:39
mveOriginalGriff17-Mar-21 11:39 
GeneralRe: CS1929 Pin
Josh Vanbaalen17-Mar-21 13:40
Josh Vanbaalen17-Mar-21 13:40 
GeneralRe: CS1929 Pin
OriginalGriff17-Mar-21 21:02
mveOriginalGriff17-Mar-21 21:02 
QuestionReading USB Tilt Pin
Luis M. Rojas16-Mar-21 2:48
Luis M. Rojas16-Mar-21 2:48 
AnswerRe: Reading USB Tilt Pin
Pete O'Hanlon16-Mar-21 2:54
mvePete O'Hanlon16-Mar-21 2:54 
GeneralRe: Reading USB Tilt Pin
Luis M. Rojas16-Mar-21 4:06
Luis M. Rojas16-Mar-21 4:06 
AnswerRe: Reading USB Tilt Pin
OriginalGriff16-Mar-21 3:16
mveOriginalGriff16-Mar-21 3:16 
AnswerRe: Reading USB Tilt Pin
Dave Kreskowiak16-Mar-21 3:46
mveDave Kreskowiak16-Mar-21 3:46 
QuestionIs there a way to open firefox driver in mobile emulation mode in selenium c# MSTest Pin
Member 1485915115-Mar-21 19:55
Member 1485915115-Mar-21 19:55 
AnswerRe: Is there a way to open firefox driver in mobile emulation mode in selenium c# MSTest Pin
Richard Deeming15-Mar-21 22:37
mveRichard Deeming15-Mar-21 22:37 
QuestionIIS application pool Hangs for Webservice developed in C# Pin
Member 1510093115-Mar-21 10:36
Member 1510093115-Mar-21 10:36 
QuestionExpand/Collapse TreeView Nodes on Ctrl+LeftMouse in WPF Pin
ernie_hudds12-Mar-21 2:55
ernie_hudds12-Mar-21 2:55 
AnswerRe: Expand/Collapse TreeView Nodes on Ctrl+LeftMouse in WPF Pin
OriginalGriff12-Mar-21 4:17
mveOriginalGriff12-Mar-21 4:17 
Question.NET native vs. custom localization Pin
Niemand2510-Mar-21 23:18
professionalNiemand2510-Mar-21 23:18 
AnswerRe: .NET native vs. custom localization Pin
Gerry Schmitz11-Mar-21 7:20
mveGerry Schmitz11-Mar-21 7:20 
AnswerRe: .NET native vs. custom localization Pin
lmoelleb15-Mar-21 22:40
lmoelleb15-Mar-21 22:40 
QuestionContinue program after encountering error Pin
Member 1447460710-Mar-21 10:05
Member 1447460710-Mar-21 10:05 
AnswerRe: Continue program after encountering error Pin
Dave Kreskowiak10-Mar-21 10:14
mveDave Kreskowiak10-Mar-21 10:14 
GeneralRe: Continue program after encountering error Pin
Member 1447460710-Mar-21 10:35
Member 1447460710-Mar-21 10:35 
GeneralRe: Continue program after encountering error Pin
Dave Kreskowiak10-Mar-21 11:05
mveDave Kreskowiak10-Mar-21 11:05 
GeneralRe: Continue program after encountering error Pin
Gerry Schmitz11-Mar-21 7:23
mveGerry Schmitz11-Mar-21 7:23 
AnswerRe: Continue program after encountering error Pin
NotTodayYo10-Mar-21 10:52
NotTodayYo10-Mar-21 10:52 
AnswerRe: Continue program after encountering error Pin
Eddy Vluggen10-Mar-21 11:24
professionalEddy Vluggen10-Mar-21 11:24 
AnswerRe: Continue program after encountering error Pin
OriginalGriff10-Mar-21 21:17
mveOriginalGriff10-Mar-21 21:17 
QuestionHow to pass an array or structs to DeviceIoControl when using pinvoke Pin
BobZscharnagk7-Mar-21 22:13
BobZscharnagk7-Mar-21 22:13 
I'm trying to get the list of allocated ranges for a sparse file on Windows 10 from a C# program. DeviceIOControl requires an array of FILE_ALLOCATED_RANGE_BUFFER structures as the output buffer. I just can't seem to get the correct way of passing these. So far I have....

public static bool GetSparseRange(SafeFileHandle hdrive, in FILE_ALLOCATED_RANGE_BUFFER query, ref FILE_ALLOCATED_RANGE_BUFFER[] response, int count)
{
int nInBufferSize = (int)Marshal.SizeOf(typeof(FILE_ALLOCATED_RANGE_BUFFER));
IntPtr lpInBuffer = Marshal.AllocHGlobal(nInBufferSize);
Marshal.StructureToPtr(query, lpInBuffer, true);
uint bytesread=0;
IntPtr[] ptrArr = new IntPtr[count];
for (int i = 0; i < count; ++i)
{
ptrArr[i] = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FILE_ALLOCATED_RANGE_BUFFER)));
Marshal.StructureToPtr(response[i], ptrArr[i], true);
}
bool rc = DeviceIoControl(
hdrive, // device to be queried
(uint)EIOControlCode.FsctlQueryAllocatedRanges, // operation to perform
lpInBuffer, (uint)nInBufferSize, // input buffer
ptrArr, (uint)(nInBufferSize * count)), // output buffer
ref bytesread, // # bytes returned
IntPtr.Zero); // synchronous I/O
// Get the last error and display it.
int error = Marshal.GetLastWin32Error();
for (int j = 0; j < count / nInBufferSize; ++j)
{
if (j < bytesread / nInBufferSize)
Marshal.PtrToStructure(ptrArr[j], response[j]);
Marshal.FreeHGlobal(ptrArr[j]);
}
Marshal.FreeHGlobal(lpInBuffer);
return rc;
}

However this return rc=false, byteread=0 and error=5.

Can anyone suggest the correct way to do this?

Thanks

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.