C # How to call the desert plug-in

Source: Internet
Author: User

From http://blog.csdn.net/lsgy2008/article/details/8216484

1. Convert DM. DLL to. net.ProgramSet. Method: Enter tlbimp D: \ DM. dll/out: D: \ dmnet. dll in the Visual Studio command prompt.

 

2. Register DM. dll. Register the source DM. dll.Code

[CSHARP] View plaincopyprint?
  1. /// <Summary>
  2. /// Register
  3. /// </Summary>
  4. /// <Param name = "strcmd"> </param>
  5. /// <Returns> </returns>
  6. Static StringAutoregcom (StringStrcmd)
  7. {
  8. Strcmd ="Regsvr32 D: \ DM. dll/S";
  9. StringRinfo;
  10. Try
  11. {
  12. Process myprocess =NewProcess ();
  13. Processstartinfo myprocessstartinfo =NewProcessstartinfo ("Cmd.exe");
  14. Myprocessstartinfo. useshellexecute =False;
  15. Myprocessstartinfo. createnowindow =True;
  16. Myprocessstartinfo. redirectstandardoutput =True;
  17. Myprocess. startinfo = myprocessstartinfo;
  18. Myprocessstartinfo. Arguments ="/C"+ Strcmd;
  19. Myprocess. Start ();
  20. Streamreader mystreamreader = myprocess. standardoutput;
  21. Rinfo = mystreamreader. readtoend ();
  22. Myprocess. Close ();
  23. Rinfo = strcmd +"\ R \ n"+ Rinfo;
  24. ReturnRinfo;
  25. }
  26. Catch(Exception ex)
  27. {
  28. ReturnEx. message;
  29. }
  30. }
/// <Summary> /// register /// </Summary> /// <Param name = "strcmd"> </param> /// <returns> </ returns> static string autoregcom (string strcmd) {strcmd = "regsvr32 D: \ DM. dll/s "; string rinfo; try {process myprocess = new process (); processstartinfo myprocessstartinfo = new processstartinfo (" cmd.exe "); myprocessstartinfo. useshellexecute = false; myprocessstartinfo. createnowindow = true; myprocessstartinfo. redirectstandardoutput = true; myprocess. startinfo = myprocessstartinfo; myprocessstartinfo. arguments = "/C" + strcmd; myprocess. start (); streamreader mystreamreader = myprocess. standardoutput; rinfo = mystreamreader. readtoend (); myprocess. close (); rinfo = strcmd + "\ r \ n" + rinfo; return rinfo;} catch (exception ex) {return ex. message ;}}

Source code example:

 

 

[CSHARP] View plaincopyprint?
  1. UsingSystem;
  2. UsingSystem. Collections. Generic;
  3. UsingSystem. componentmodel;
  4. UsingSystem. Data;
  5. UsingSystem. diagnostics;
  6. UsingSystem. drawing;
  7. UsingSystem. IO;
  8. UsingSystem. LINQ;
  9. UsingSystem. text;
  10. UsingSystem. Threading. tasks;
  11. UsingSystem. Windows. forms;
  12. UsingDmnet;
  13. NamespaceDmtest
  14. {
  15. PublicPartialClassForm1: Form
  16. {
  17. PublicForm1 ()
  18. {
  19. Initializecomponent ();
  20. Autoregcom ("Regsvr32 D: \ DM. dll/S");
  21. }
  22. Private VoidButton#click (ObjectSender, eventargs E)
  23. {
  24. Dmsoft dm =NewDmsoft ();
  25. Textbox1.text = DM. findwindow ("","T"). Tostring ();
  26. DM. moveTo (30, 30 );
  27. }
  28. /// <Summary>
  29. /// Register
  30. /// </Summary>
  31. /// <Param name = "strcmd"> </param>
  32. /// <Returns> </returns>
  33. Static StringAutoregcom (StringStrcmd)
  34. {
  35. Strcmd ="Regsvr32 D: \ DM. dll/S";
  36. StringRinfo;
  37. Try
  38. {
  39. Process myprocess =NewProcess ();
  40. Processstartinfo myprocessstartinfo =NewProcessstartinfo ("Cmd.exe");
  41. Myprocessstartinfo. useshellexecute =False;
  42. Myprocessstartinfo. createnowindow =True;
  43. Myprocessstartinfo. redirectstandardoutput =True;
  44. Myprocess. startinfo = myprocessstartinfo;
  45. Myprocessstartinfo. Arguments ="/C"+ Strcmd;
  46. Myprocess. Start ();
  47. Streamreader mystreamreader = myprocess. standardoutput;
  48. Rinfo = mystreamreader. readtoend ();
  49. Myprocess. Close ();
  50. Rinfo = strcmd +"\ R \ n"+ Rinfo;
  51. ReturnRinfo;
  52. }
  53. Catch(Exception ex)
  54. {
  55. ReturnEx. message;
  56. }
  57. }
  58. }
  59. }
Using system; using system. collections. generic; using system. componentmodel; using system. data; using system. diagnostics; using system. drawing; using system. io; using system. LINQ; using system. text; using system. threading. tasks; using system. windows. forms; using dmnet; namespace dmtest {public partial class form1: FORM {public form1 () {initializecomponent (); autoregcom ("regsvr32 D: \ DM. dll/s ");} private void button#click (Object sender, eventargs e) {dmsoft dm = new dmsoft (); textbox1.text = DM. findwindow ("", "T "). tostring (); DM. moveTo (30, 30 );} /// <summary> /// register /// </Summary> /// <Param name = "strcmd"> </param> /// <returns> </ returns> static string autoregcom (string strcmd) {strcmd = "regsvr32 D: \ DM. dll/s "; string rinfo; try {process myprocess = new process (); processstartinfo myprocessstartinfo = new processstartinfo (" cmd.exe "); myprocessstartinfo. useshellexecute = false; myprocessstartinfo. createnowindow = true; myprocessstartinfo. redirectstandardoutput = true; myprocess. startinfo = myprocessstartinfo; myprocessstartinfo. arguments = "/C" + strcmd; myprocess. start (); streamreader mystreamreader = myprocess. standardoutput; rinfo = mystreamreader. readtoend (); myprocess. close (); rinfo = strcmd + "\ r \ n" + rinfo; return rinfo;} catch (exception ex) {return ex. message ;}}}}

I tried it today. C # does not support many programming methods, such as starting a program or inputting strings. Desert does not support C # very well. I don't know if other friends have tried it. Let's talk about it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.