|
Hi
can u explain me what wsdl exactly is and where actually u are going ot use it ....
Any links for this topics will be very helpful...
Thanks
Atul
|
|
|
|
|
|
Hi,
I'm trying (only trying) to write a C# wrapper for the WinPcap library. Of course I started with the simplest function: Get the version of the lib. This works fine
Second thing: I tried to wrap the PacketGetAdapterNames() function (also pretty simple). Here's the source code:
//----------------------------------------------------------------------------
//WinPcap API Source code:
BOOLEAN PacketGetAdapterNames(PTSTR pStr,PULONG BufferSize)
{
HKEY LinkageKey,AdapKey;
UINT RegKeySize=0;
LONG Status;
ULONG Result;
PTSTR BpStr;
char *TTpStr,*DpStr,*DescBuf;
LPADAPTER adapter;
PPACKET_OID_DATA OidData;
int i=0,k,rewind,dim;
TCHAR AdapName[256];
ODSEx("PacketGetAdapterNames: BufferSize=%d\n",*BufferSize);
OidData=GlobalAllocPtr(GMEM_MOVEABLE | GMEM_ZEROINIT,512);
if (OidData == NULL) {
...
//----------------------------------------------------------------------------
//C#wrapper code I wrote:
[DllImport("packet.dll")]
extern static bool PacketGetAdapterNames(ref string pStr, ref ulong BufferSize);
//----------------------------------------------------------------------------
The function always returns false and the ref param variables are never updated (.
I have got a sample C app with source code, that uses the same API. This app works fine...
//----------------------------------------------------------------------------
WCHAR AdapterName[8192]; // string that contains a list of the network adapters
AdapterLength=4096;
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE)
{
printf("Unable to retrieve the list of the adapters!\n");
return -1;
}
temp=AdapterName;
temp1=AdapterName;
while ((*temp!='\0')||(*(temp-1)!='\0'))
{...
-----------------------------------------------------------------------------------------
Has anybody got an idea?? I'm not very familiar with these kind of API calls.
G
|
|
|
|
|
A long in Win32 API is 32-bits, a long in .NET is 64 bits while an int is 32 bits.
If the string being passed in is a buffer (looks like it is) you should also be using StringBuilder instead of string.
With those two changes I come up with
[DllImport("packet.dll")]<br />
extern static bool PacketGetAdapterNames(StringBuilder pStr, ref uint BufferSize);
void GetAdapterNames() <br />
{<br />
System.Text.StringBuilder AdapterNames = new System.Text.StringBuilder(bufferSize);<br />
uint bufSize = (uint) bufferSize;<br />
<br />
PacketGetAdapterNames(AdapterNames, ref bufSize);<br />
}
I don't think ref is needed on the buffer because it will be passed like a char array to the function by the marshaler, putting ref on the buffer would be equivelant to WCHAR** in C/C++.
HTH,
James
Simplicity Rules!
|
|
|
|
|
You're the man! Thanks, it worked.
G
|
|
|
|
|
James,
Thanks again. I've got another question. Any idea how I can make a struct in C# that is the equivalent of: ??
typedef struct ADAPTER {
HANDLE hFile;
TCHAR SymbolicLink[MAX_LINK_NAME_LENGTH];
int NumWrites;
HANDLE ReadEvent;
UINT ReadTimeOut;
};
typedef struct PACKET {
PVOID Buffer;
UINT Length;
UINT ulBytesReceived;
BOOLEAN bIoComplete;
};
Thanks, G
|
|
|
|
|
Untested, but might work
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]<br />
public struct ADAPTER<br />
{<br />
public IntPtr hFile;<br />
public StringBuilder SymbolicLink;<br />
public int NumWrites;<br />
public IntPtr ReadEvent;<br />
public uint ReadTimeOut;<br />
}<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public struct PACKET<br />
{<br />
public byte [] Buffer;<br />
public uint Length;<br />
public uint ulBytesReceived;<br />
public bool bIoComplete;<br />
}
Good Luck
James
Simplicity Rules!
|
|
|
|
|
James,
(Not knowing anything about the WinPcap Library)
Explain to me why using a StringBuilder in place of the TCHAR SymbolicLink[MAX_LINK_NAME_LENGTH] array would work here?
Wouldn't a variation of something like the following be the right choice?
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=MAX_LINK_NAME_LENGTH )]
public String SymbolicLink;
Thanks,
Neil
|
|
|
|
|
I don't know :-P
I originally had written what you had, then switched it to StringBuilder.
James
Simplicity Rules!
|
|
|
|
|
I am confident that the attributed string as I presented, is the right choice.
The StringBuilder reference is the size of a pointer, in contrast to the TCHAR array being n TCHAR(s) in length (+ alignment padding if necessary), directly affecting the size of the overall structure and the offsets of its members.
Regards
|
|
|
|
|
does .net framework support font's weight(in pounds)? i only can set bold in Font class.
And i see a method called FromLogFont may help me.
But how can i get reach to the stucture defined in former GDI?
|
|
|
|
|
hi!
I thing I found a bug in TreeView AfterCheck event but
I´m not 100 % sure.
this is my event (C#):
private void displaySaleContractTreeView_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
e.Node.Nodes[1].Checked = true;
e.Node.Nodes[2].Checked = true;
e.Node.Nodes[2].Nodes[0].Checked = true;
e.Node.Nodes[2].Nodes[1].Checked = true;
e.Node.Nodes[2].Nodes[2].Checked = true;
e.Node.Nodes[2].Nodes[3].Checked = true;
e.Node.Nodes[2].Nodes[4].Checked = true;
e.Node.Nodes[2].Nodes[5].Checked = true;
e.Node.Nodes[2].Nodes[6].Checked = true;
e.Node.Nodes[2].Nodes[7].Checked = true;
e.Node.Nodes[3].Checked = true;
MessageBox.Show("TEST");
}
what VS.NEt make:
at first it go to e.Node.Nodes[1].Checked = true;
then VS.NET go not to e.Node.Nodes[2].Checked = true;
VS.NET go again to e.Node.Nodes[1].Checked = true;
after this i become a message:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values.
why that doesn´t work?
but it work something like this:
private void displaySaleContractTreeView_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
e.Node.Nodes[1].ForeColor = Color.Red;
e.Node.Nodes[2].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[0].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[1].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[2].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[3].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[4].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[5].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[6].ForeColor = Color.Red;
e.Node.Nodes[2].Nodes[7].ForeColor = Color.Red;
e.Node.Nodes[3].ForeColor = Color.Red;
MessageBox.Show("TEST");
}
is it ahain a bug in VS.NET???
Pawel
|
|
|
|
|
I was working on a sample in Jesse Liberty's "Programming C#" book today and had the same problem. For some reason the code killed the application without an exception. Basically, it looked as though setting the Checked property fires the AfterCheck event. This causes a recursion that kills the program.
This seems to be different that the behavior I am used to (in say VB).
Also, remember that arrays start at zero. Nodes[0], Nodes[1], and Nodex[2] for a node with three child nodes.
You may also want to protect your code to prevent multiple firing of the AfterCheck event.
Boy. How ya gonna keep 'em down on the farm once they seen Karl Hungus.
<p style="text-align: right; margin: 0px;">- The Dude :cool:</p>
|
|
|
|
|
hi!
I have get a replay for me message on an other message board with the solution for this problem. and here is the replay message:
Re: A bug in TreeView AfterCheck event? Posted on: April 12 2002 12:10
Pawel,
By setting e.Node.Nodes[1].Checked = true;
you are firing a new event (because the checked was changed) and displaySaleContractTreeView_AfterCheck will be invoked again even before you come to the second line. I believe you are coming into an infinite loop here.
Anyhow, try to disable the AfterCheck event and enable it again at the end of your handler like this:
private void displaySaleContractTreeView_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
displaySaleContractTreeView.AfterCheck -= new System.Windows.Forms.AfterCheckEventHandler(this.displaySaleContractTreeView_AfterCheck);
e.Node.Nodes[1].Checked = true;
//..
//... do your stuff here
// ..
displaySaleContractTreeView.AfterCheck += new System.Windows.Forms.AfterCheckEventHandler(this.displaySaleContractTreeView_AfterCheck);
}
Hope this works,
Viel Spass,
Minh.
----------------------------------------------------
wow!!
thx!!
for every bug has enderminh a solution!!
IT´s WORK!!!!!!!!!!!!!!!
but some events that you used doesn´t exist.
this is the 100% correct code:
private void displaySaleContractTreeView_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
displaySaleContractTreeView.AfterCheck -= new System.Windows.Forms.TreeViewEventHandler(this.displaySaleContractTreeView_AfterCheck);
e.Node.Nodes[1].Checked = true;
e.Node.Nodes[2].Checked = true;
e.Node.Nodes[2].Nodes[0].Checked = true;
e.Node.Nodes[2].Nodes[1].Checked = true;
e.Node.Nodes[2].Nodes[2].Checked = true;
e.Node.Nodes[2].Nodes[3].Checked = true;
e.Node.Nodes[2].Nodes[4].Checked = true;
e.Node.Nodes[2].Nodes[5].Checked = true;
e.Node.Nodes[2].Nodes[6].Checked = true;
e.Node.Nodes[2].Nodes[7].Checked = true;
e.Node.Nodes[3].Checked = true;
displaySaleContractTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.displaySaleContractTreeView_AfterCheck);
}
thx again!!
DANKE!!
Pawel
-------------------------------------------
Pawel,
No, it's not a bug. It supposed to happen. You have said that "ey, if anyone changes this checkbox, please let me know and run this method". But since you are changing the checkbox inside this own method, it will recursively call this method again. It is supposed to happen. You are still registered to this event. It's like putting the microphone in front of your speaker, I guess.
Minh.
-----------------------------------------------
Pawel
|
|
|
|
|
I have an ImageList that I created using Icon (*.ico) files. I would like
to extract an image as an Icon, but casting doesn't work:
Icon test = (Icon)imgList.Images[1];
I know I can access the original .ico file from disk or resource, but since
it was already loaded in an ImageList, I thought this would be an easier
method. Does anyone know if this is possible?
Thanks!
|
|
|
|
|
the Bitmap class has a GetHicon() function. and the Icon class has an FromHandle(IntPtr) static function.
so, maybe something like
Icon test = Icon.FromHandle(GetHicon(imgList.Images[1]));
does it?
:wq
|
|
|
|
|
Thanks! Based on your suggestion, here's what worked:
Icon test = Icon.FromHandle(new Bitmap(imgList.Images[1]).GetHicon());
Thanks again!
Derek
|
|
|
|
|
How to make a combobox uneditable?
Thank you for your solution and attention.
Regards
|
|
|
|
|
How do you want it uneditable? So you can't change the text that is picked from the list?
myComboBox.DropDownStyle = ComboBoxStyle.DropDownList; does that
If you want to make it so that you can't even change which value is selected then set the Enabled property to false.
HTH,
James
Simplicity Rules!
|
|
|
|
|
I have a COM object with 2 interfaces, IClient and IClient2.
Using the object with the first interface is easy, I just add it to my project with "Project/Add Reference", and create it like this:
Client tc = new Client();
Then I get access to all the functions in the IClient interface.
But, I also have e newer interface, IClient2, which implements all methods from IClient and some new ones, but I can't figure out how to use IClient2
Anyone have a good idea?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
In case you don't get any answers here, the DOTNET mailing list has fielded a TON of questions on COM interop; something I haven't had to do which is why I can't answer your question.
Sorry I don't have a straight-up answer,
James
Simplicity Rules!
|
|
|
|
|
Try this :-
C# program :- Clipboard.SetDataObject(new Bitmap("D:\\nish.bmp"),true);
Now try to paste that into Paint Brush or MS Word or Adobe Photoshop or any other non-.NET app.
It will fail!!!
Why?????????????
Nish
One little CD gone,
Then two CDs gone,
Then 5 more gone,
For a total 7 gones,
If I was a CD R,
I'd wanna cry,
Cause I'd be just a goner,
For a nasty CD burner.
[funny how frustration wakes up the poet in me]
|
|
|
|
|
We've narrowed it down to a problem with Beta 2, poor Nish has to upgrade now and lose VS.NET
James
Simplicity Rules!
|
|
|
|
|
Yeah, this really sucks!!!
Nish
One little CD gone,
Then two CDs gone,
Then 5 more gone,
For a total 7 gones,
If I was a CD R,
I'd wanna cry,
Cause I'd be just a goner,
For a nasty CD burner.
[funny how frustration wakes up the poet in me]
|
|
|
|
|
How would I go about displaying a HTML document inside a windows form? Is there a control that can display HTML text?
|
|
|
|