Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a C++ DLL from C#
    text
    copied!<p>I am making a program to control a laser but to do that I need to import a dll into c# and call functions with it. The original program is written in C++ and I just cant figure it out how to do it. So my questions are:</p> <ol> <li>How to import a dll in c#</li> <li>how to call the functions from C++ in c#</li> </ol> <p>To make it a bit more clear to you I've added the code from the C++ program.</p> <pre><code>#include "MarkEzdDll.h" class CDemoEzdDlg : public CDialog { // Construction public: CDemoEzdDlg(CWnd* pParent = NULL); // standard constructor HINSTANCE m_hEzdDLL;//DLLµ÷Óþä±ú LMC1_INITIAL lmc1_Initial; LMC1_CLOSE lmc1_Close; LMC1_LOADEZDFILE lmc1_LoadEzdFile; LMC1_MARK lmc1_Mark; LMC1_MARKENTITY lmc1_MarkEntity; LMC1_GETPREVBITMAP lmc1_GetPrevBitmap; LMC1_READPORT lmc1_ReadPort; LMC1_WRITEPORT lmc1_WritePort; LMC1_SETDEVCFG lmc1_SetDevCfg; LMC1_SETHATCHPARAM lmc1_SetHatchParam; LMC1_SETFONTPARAM lmc1_SetFontParam; LMC1_GETPENPARAM lmc1_GetPenParam; LMC1_SETPENPARAM lmc1_SetPenParam; LMC1_CLEARENTLIB lmc1_ClearEntLib; LMC1_ADDTEXTTOLIB lmc1_AddTextToLib; LMC1_ADDFILETOLIB lmc1_AddFileToLib; LMC1_ADDBARCODETOLIB lmc1_AddBarCodeToLib; LMC1_CHANGETEXTBYNAME lmc1_ChangeTextByName; LMC1_AXISMOVETO lmc1_AxisMoveTo; LMC1_AXISCORRECTORIGIN lmc1_AxisCorrectOrigin; LMC1_GETAXISCOOR lmc1_GetAxisCoor; LMC1_SAVEENTLIBTOFILE lmc1_SaveEntLibToFile; </code></pre> <p>in the dialog, there is a button which has this code attached to it:</p> <pre><code>void CDemoEzdDlg::OnButtonRun() { // TODO: Add your control notification handler code here UpdateData(); if(lmc1_Mark==NULL) { return; } lmc1_Mark(FALSE); UpdatePrevBmp(); AfxMessageBox(_T("Mark file finish!")); } </code></pre> <p>This is when the laser should start.</p> <p>How to get this in c#?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload