Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. VC++ DLL LIB and OCX in C# Win Form Application

VC++ DLL LIB and OCX in C# Win Form Application

Scheduled Pinned Locked Moved C#
csharpc++cssdatabasevisual-studio
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Karmendra Suthar
    wrote on last edited by
    #1

    Hi, I purchased an USB based oscilloscope DSO-2150 from Hantek. Along with it came the VC++ DLLs (dll, lib and ocx). I need to create a Winform application using C# Visual Studio Express Edition. Please tell me is it possible to use VC++6 DLL in a C# appllication and if yes How? Following is scrap from the manual provided with the DLL files.

    DSO-XXXX USB SDK Manual

    SDKXXXX.dll (VC++ 6.0)

    Define struct
    struct PictureRange{ // Be used for draw grid
    WORD width; // the width of display range
    WORD height; // the height of display range
    WORD left; //the left of display range
    WORD right; //the right of display range
    WORD top; //the top of display range
    WORD bottom; //the bottom of display range
    };
    struct ControlStruct{ //save the control data
    WORD TriggerSource; //the trigger source
    WORD SelectedChannel; // the display channel
    WORD Timebase; // timebase
    WORD TriggerPosition; // the trigger vertical position “0%,25%,50%,75%,100%”
    WORD DataLengh; // its value is 1 or 2, if BufferSize = 10, Datalengh = 1, else Datalengh =2
    WORD BufferSize ; //Its value is 10,32 or 64
    WORD isAlt; //If ALT trigger, its value is 1, else 0.
    };
    struct LeversStruct{ //save position
    WORD Ch1Position; // the ch1 waveform horizontal position
    WORD Ch2 Position; // the ch2 waveform horizontal position
    WORD Ch1TriggerPosition; // the ch1 trigger position
    WORD Ch2TriggerPosition; // the ch2 trigger position
    WORD EXTTriggerPosition; // the EXT trigger position
    };
    struct StateStruct{
    WORD Ch1Filt; // ch1 filter
    WORD Ch2Filt; //ch2 filter
    WORD TriggerFilt; // trigger filter
    WORD TriggerMode; //trigger mode (AUTO, NORMAL, SINGLE)
    WORD TriggerSlope; //trigger slope (rising edge, failing edge)
    };
    struct LineColor{ // the waveform color
    WORD R;
    WORD G;
    WORD B;
    };

    struct AutosetStruct{ //save the autoset data
    WORD WhichChannel; //which channel will autoset
    WORD Ch1Voltage; //Ch1 autoset voltage
    WORD Ch2Voltage; //Ch2 autoset voltage
    WORD Ch1Timebase; //Ch1 autoset timebase
    WORD Ch2Timebase; //Ch2 autoset timebase
    WORD Ch1InGND; //Ch1 is in GND or not
    WORD Ch2InGND; //Ch2 is in GND or not
    WORD Ch1Enabled; //Ch1 enabled
    WORD Ch2Enabled; //Ch2 enabled
    };
    struct TimeStruct{ //Save the time
    double Timer; // the number of seconds elapsed since midnight
    double Time; //the time of Timebase
    double ScrollTime;
    double ScrollStart;
    };
    Funct

    L 1 Reply Last reply
    0
    • K Karmendra Suthar

      Hi, I purchased an USB based oscilloscope DSO-2150 from Hantek. Along with it came the VC++ DLLs (dll, lib and ocx). I need to create a Winform application using C# Visual Studio Express Edition. Please tell me is it possible to use VC++6 DLL in a C# appllication and if yes How? Following is scrap from the manual provided with the DLL files.

      DSO-XXXX USB SDK Manual

      SDKXXXX.dll (VC++ 6.0)

      Define struct
      struct PictureRange{ // Be used for draw grid
      WORD width; // the width of display range
      WORD height; // the height of display range
      WORD left; //the left of display range
      WORD right; //the right of display range
      WORD top; //the top of display range
      WORD bottom; //the bottom of display range
      };
      struct ControlStruct{ //save the control data
      WORD TriggerSource; //the trigger source
      WORD SelectedChannel; // the display channel
      WORD Timebase; // timebase
      WORD TriggerPosition; // the trigger vertical position “0%,25%,50%,75%,100%”
      WORD DataLengh; // its value is 1 or 2, if BufferSize = 10, Datalengh = 1, else Datalengh =2
      WORD BufferSize ; //Its value is 10,32 or 64
      WORD isAlt; //If ALT trigger, its value is 1, else 0.
      };
      struct LeversStruct{ //save position
      WORD Ch1Position; // the ch1 waveform horizontal position
      WORD Ch2 Position; // the ch2 waveform horizontal position
      WORD Ch1TriggerPosition; // the ch1 trigger position
      WORD Ch2TriggerPosition; // the ch2 trigger position
      WORD EXTTriggerPosition; // the EXT trigger position
      };
      struct StateStruct{
      WORD Ch1Filt; // ch1 filter
      WORD Ch2Filt; //ch2 filter
      WORD TriggerFilt; // trigger filter
      WORD TriggerMode; //trigger mode (AUTO, NORMAL, SINGLE)
      WORD TriggerSlope; //trigger slope (rising edge, failing edge)
      };
      struct LineColor{ // the waveform color
      WORD R;
      WORD G;
      WORD B;
      };

      struct AutosetStruct{ //save the autoset data
      WORD WhichChannel; //which channel will autoset
      WORD Ch1Voltage; //Ch1 autoset voltage
      WORD Ch2Voltage; //Ch2 autoset voltage
      WORD Ch1Timebase; //Ch1 autoset timebase
      WORD Ch2Timebase; //Ch2 autoset timebase
      WORD Ch1InGND; //Ch1 is in GND or not
      WORD Ch2InGND; //Ch2 is in GND or not
      WORD Ch1Enabled; //Ch1 enabled
      WORD Ch2Enabled; //Ch2 enabled
      };
      struct TimeStruct{ //Save the time
      double Timer; // the number of seconds elapsed since midnight
      double Time; //the time of Timebase
      double ScrollTime;
      double ScrollStart;
      };
      Funct

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, that seems doable, but it is not at a beginner's level. You will need a lot of P/Invoke. If you are not familiar with P/Invoke, I suggest: - you read up on it, both MSDN and some CodeProject articles; - you have a look at www.pinvoke.net[^] - you start with something simpler; I like to create my own native C coded DLL, using simple functions to test P/Invoke stuff. BTW: for the array stuff (where parameters are pointers) you either need to use the fixed and unsafe keywords, or the GCHandle class. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Love, happiness and fewer bugs for 2009!


      K 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, that seems doable, but it is not at a beginner's level. You will need a lot of P/Invoke. If you are not familiar with P/Invoke, I suggest: - you read up on it, both MSDN and some CodeProject articles; - you have a look at www.pinvoke.net[^] - you start with something simpler; I like to create my own native C coded DLL, using simple functions to test P/Invoke stuff. BTW: for the array stuff (where parameters are pointers) you either need to use the fixed and unsafe keywords, or the GCHandle class. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Love, happiness and fewer bugs for 2009!


        K Offline
        K Offline
        Karmendra Suthar
        wrote on last edited by
        #3

        Hi Luc Thanks, It really seems tedious, need to learn lot to understand it. A friend of mine was suggesting adding a reference to dll and that will create a class for me to use directly. But he said I has not tried it anytime, what do you think is that possible. Thanks again, Regards, Karmendra

        L 1 Reply Last reply
        0
        • K Karmendra Suthar

          Hi Luc Thanks, It really seems tedious, need to learn lot to understand it. A friend of mine was suggesting adding a reference to dll and that will create a class for me to use directly. But he said I has not tried it anytime, what do you think is that possible. Thanks again, Regards, Karmendra

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, C# calling native code needs P/Invoke, AFAIK there is no way around that. Ask your friend for details of his method! :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Love, happiness and fewer bugs for 2009!


          K 1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, C# calling native code needs P/Invoke, AFAIK there is no way around that. Ask your friend for details of his method! :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            Love, happiness and fewer bugs for 2009!


            K Offline
            K Offline
            Karmendra Suthar
            wrote on last edited by
            #5

            Hi Luc, I just found i even have VB dlls does that help getting it done the easier way, I mean I don't mind learning new things, but don't have much time, but if their is no other go i will keep learning about accessing un-managed code in c# using pInvoke. Thanks a lot for your help, Regards, Karmendra Suthar

            L 1 Reply Last reply
            0
            • K Karmendra Suthar

              Hi Luc, I just found i even have VB dlls does that help getting it done the easier way, I mean I don't mind learning new things, but don't have much time, but if their is no other go i will keep learning about accessing un-managed code in c# using pInvoke. Thanks a lot for your help, Regards, Karmendra Suthar

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Hi, if that is old VB stuff, it is still native code and C# needs P/Invoke. if that is managed VB.NET code, then it can be called directly, just instantiate the classes and operate on the properties and methods as if it too were C# code. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              Love, happiness and fewer bugs for 2009!


              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups