Hello Everyone,
I am having an issue using an API and was wondering if you could point out what I am doing wrong. The error that I am getting is 'The paramater is not correct.' I am unable to figure out what paramater the error is referring to.
The API Call is WTSVirtualChannelRead and below is the signature from MSDN.
Thanks in advance
//////////////////////////////////
// //
// BOOL WTSVirtualChannelRead( //
// HANDLE hChannelHandle, //
// ULONG TimeOut, //
// PCHAR Buffer, //
// ULONG BufferSize, //
// PULONG pBytesRead //
// ); //
// //
/////////////////////////////////
[DllImport("Wtsapi32.dll", SetLastError = true)]
private static extern bool WTSVirtualChannelRead(IntPtr handle,
int timeout,
ref byte[] buffer,
int readlength,
ref int bytesRead);
void buttonClick(..)
{
int intHandle =0;
byte[] bytes =new byte[0];
int bytesRead =0;
if(success = Win32.WtsApi32.WTSVirtualChannelQuery(
mHandle,
(int)1, //file handle
ref intHandle,
ref bytesRead
))
{
bytesRead=0;
IntPtr intHandlePtr=(IntPtr)intHandle;
//Wait for 5 seconds before timing out
//Channel Chunk size is 1600 bytes
if(!WTSVirtualChannelRead(intHandlePtr, (int)5000, ref bytes, (int)1600, ref bytesRead))
{
try
{ throw new Win32Exception(Marshal.GetLastWin32Error()); }
catch (Win32Exception e)
{ Console.WriteLine("Read Error:" + e.ToString()); }
}
else
{
Console.WriteLine("Success!");
}
}
} 2 2601
Hi,
Take a look at pinvoke.net . Most probably you have your native method incorrectly declared.
If the method in question is not found just look for a method (or methods) that have the same kind of parameters and see how the managed version is declared.
"amdrit" <am****@hotmail.comwrote in message news:ul****************@TK2MSFTNGP04.phx.gbl...
Hello Everyone,
I am having an issue using an API and was wondering if you could point out what I am doing wrong. The error that I am getting is 'The paramater is not correct.' I am unable to figure out what paramater the error is referring to.
The API Call is WTSVirtualChannelRead and below is the signature from MSDN.
Thanks in advance
//////////////////////////////////
// //
// BOOL WTSVirtualChannelRead( //
// HANDLE hChannelHandle, //
// ULONG TimeOut, //
// PCHAR Buffer, //
// ULONG BufferSize, //
// PULONG pBytesRead //
// ); //
// //
/////////////////////////////////
[DllImport("Wtsapi32.dll", SetLastError = true)]
private static extern bool WTSVirtualChannelRead(IntPtr handle,
int timeout,
ref byte[] buffer,
int readlength,
ref int bytesRead);
void buttonClick(..)
{
int intHandle =0;
byte[] bytes =new byte[0];
int bytesRead =0;
if(success = Win32.WtsApi32.WTSVirtualChannelQuery(
mHandle,
(int)1, //file handle
ref intHandle,
ref bytesRead
))
{
bytesRead=0;
IntPtr intHandlePtr=(IntPtr)intHandle;
//Wait for 5 seconds before timing out
//Channel Chunk size is 1600 bytes
if(!WTSVirtualChannelRead(intHandlePtr, (int)5000, ref bytes, (int)1600, ref bytesRead))
{
try
{ throw new Win32Exception(Marshal.GetLastWin32Error()); }
catch (Win32Exception e)
{ Console.WriteLine("Read Error:" + e.ToString()); }
}
else
{
Console.WriteLine("Success!");
}
}
}
>[DllImport("Wtsapi32.dll", SetLastError = true)]
>private static extern bool WTSVirtualChannelRead(IntPtr handle,
int timeout,
ref byte[] buffer,
int readlength,
ref int bytesRead);
'buffer' should not be a ref parameter. You should pass in a buffer
you allocate you self by value.
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Enos Meroka |
last post by:
Hallo,
I am a student doing my project in the university.. I have been trying
to compile the program using HP -UX aCC compiler, however I keep on
getting the following errors.
...
|
by: Mike L |
last post by:
Should the command call "using" be before or after my namespace?
**AFTER**
namespace DataGridBrowser
{
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using...
|
by: xzzy |
last post by:
I was wondering why we have to have
using System.Data
using System.Configuration
using etc....
why are they not all lumped into one 'using'?
In other words, is there a best way to use...
|
by: pmud |
last post by:
Hi,
I need to use an Excel Sheet in ASP.NET application so that the users can
enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever
the USER ENETRS needs to go to the...
|
by: acb |
last post by:
Hi,
I wrote a DLL Component (using Visual Studio 2005) and managed to
include it into a C# Console application.
I am now trying to include this component into a Web project. I copy
the DLL...
|
by: Metal2You |
last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that
accesses a Sybase database back end. We're using Sybase SQL Anywhere
9.0.2.3228. I have installed and registered the Sybase...
|
by: mg |
last post by:
I'm migrating from VB6 and have a question about using 'Using' and the
best way to use it.
Here is a example of a small bit of code:
dbConx("open")
Using CN
Dim CMD As New OleDbCommand(sSQL,...
|
by: Eugene Anthony |
last post by:
The problem with my coding is that despite removing the records stored
in the array list, the rptPages repeater
control is still visible. The rptPages repeater control displayes the
navigation...
|
by: JDeats |
last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting
and decrypting a file.
http://support.microsoft.com/kb/307010
In .NET 2.0 this approach is not fully supported (a .NET 2.0...
|
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= |
last post by:
Greetings! I was researching AJAX to provide a solution to displaying status
messages while a long process executed. I found several examples online and
was able to use their code to get a quick...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |