Click here to Skip to main content
15,908,264 members
Home / Discussions / C#
   

C#

 
QuestionScreen mousemove event? Pin
14-Apr-02 23:16
suss14-Apr-02 23:16 
AnswerRe: Screen mousemove event? Pin
Nick Parker15-Apr-02 1:27
protectorNick Parker15-Apr-02 1:27 
AnswerRe: Screen mousemove event? Pin
Rüpel18-Apr-02 2:38
Rüpel18-Apr-02 2:38 
GeneralRe: Screen mousemove event? Pin
Rüpel19-Apr-02 0:01
Rüpel19-Apr-02 0:01 
GeneralEnumerating computer names in local network Pin
djnex13-Apr-02 21:56
djnex13-Apr-02 21:56 
GeneralWSDL (Web service description language) Pin
13-Apr-02 16:24
suss13-Apr-02 16:24 
GeneralRe: WSDL (Web service description language) Pin
Nick Parker15-Apr-02 12:43
protectorNick Parker15-Apr-02 12:43 
GeneralC# wrapper for the WinPcap Library Pin
HG12-Apr-02 21:25
HG12-Apr-02 21:25 
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 Smile | :)

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 Frown | :-( (.
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


GeneralRe: C# wrapper for the WinPcap Library Pin
James T. Johnson12-Apr-02 22:12
James T. Johnson12-Apr-02 22:12 
GeneralRe: C# wrapper for the WinPcap Library Pin
HG12-Apr-02 22:29
HG12-Apr-02 22:29 
GeneralRe: C# wrapper for the WinPcap Library Pin
HG12-Apr-02 23:51
HG12-Apr-02 23:51 
GeneralRe: C# wrapper for the WinPcap Library Pin
James T. Johnson13-Apr-02 0:20
James T. Johnson13-Apr-02 0:20 
GeneralRe: C# wrapper for the WinPcap Library Pin
Neil Van Note13-Apr-02 14:54
Neil Van Note13-Apr-02 14:54 
GeneralRe: C# wrapper for the WinPcap Library Pin
James T. Johnson13-Apr-02 15:09
James T. Johnson13-Apr-02 15:09 
GeneralRe: C# wrapper for the WinPcap Library Pin
Neil Van Note13-Apr-02 15:41
Neil Van Note13-Apr-02 15:41 
Generalsome problem about Font Pin
12-Apr-02 18:01
suss12-Apr-02 18:01 
QuestionA bug in TreeView AfterCheck event? Pin
gicio12-Apr-02 8:44
gicio12-Apr-02 8:44 
AnswerRe: A bug in TreeView AfterCheck event? Pin
Tom Welch12-Apr-02 8:51
Tom Welch12-Apr-02 8:51 
GeneralRe: A bug in TreeView AfterCheck event? Pin
gicio14-Apr-02 3:25
gicio14-Apr-02 3:25 
GeneralIcon from ImageList Pin
Derek Price12-Apr-02 2:19
Derek Price12-Apr-02 2:19 
GeneralRe: Icon from ImageList Pin
Rüpel18-Apr-02 2:52
Rüpel18-Apr-02 2:52 
GeneralRe: Icon from ImageList Pin
Derek Price18-Apr-02 4:40
Derek Price18-Apr-02 4:40 
QuestionHow to make a combobox uneditable? Pin
11-Apr-02 23:32
suss11-Apr-02 23:32 
AnswerRe: How to make a combobox uneditable? Pin
James T. Johnson11-Apr-02 23:35
James T. Johnson11-Apr-02 23:35 
GeneralUsing COM Objects (new interfaces) Pin
Anders Molin11-Apr-02 22:39
professionalAnders Molin11-Apr-02 22:39 

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.