Need help converting c++ to c#

  • 13 years ago

    Hi Y'all,

    can someone help me convert the next few lines of code from c++ to c#?

    I've given it a try myself but my program keeps crashing when I use my c# code. I think the difficulty lies in converting the different datatypes. Help is greatly appreciated.

    Here's tha code:

    BOOL EXAPI
    SetCallback(
          WORD  wPortNumber,
       BOOL (CALLBACK* lpfnCallbackProc)(WORD, ULONG, INT, LPCALLBACKDATA, LPVOID),
       LPVOID   lpParam,
       BOOL  bDoCoInitialize = FALSE
       );





    BOOL CALLBACK EXPORT CallbackProc(WORD wPortAddress, ULONG ulIPAddress, INT cCommand, LPCALLBACKDATA lpData, LPVOID lpParam)
    {
      return TRUE;
    }


    // Definitions for callback functions
    typedef struct tagBLOCKELEMENT {
     DWORD dwStructSize;    // structure size
     LONG nType;      // data type (see constants below)
     LPVOID lpData;      // pointer to data
    } BLOCKELEMENT, *PBLOCKELEMENT, FAR *LPBLOCKELEMENT;




    typedef struct tagCALLBACKDATA {
     DWORD   dwStructSize;  // structure size
     LONG   nStartNo;   // start number of data block
     LONG   nNumberOfElements;  // number of data elements
     LONG   nBlockMode;   // mode of block operation
     LPBLOCKELEMENT lpDataBlock;  // pointer to data block
    } CALLBACKDATA, *PCALLBACKDATA, FAR *LPCALLBACKDATA;









    Thanks in advance everyone.

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - Rick Osborne