If it's a COM dll, then you are looking into Interop.
You need to add a reference to that COM dll.
At the top of the using, include the com interface like this:
using System.Runtime.InteropServices;
using *** YourCOM ***
Then, all the COM interface should be visible to you.
The code is like this :
m_oComObject = new ComObjectClass();
After finishing, do this:
Marshal.ReleaseComObject(m_m_oComObject);
HTH
Jianwei
Thank you for your reply. But the problem is I am using third party plugin. I
must use functions of a COM-interface that the plugin provides me. I think
now my problem is more clear to you. Do you have any solutions??
RobKinney1 said:
I am afraid I am not an expert in this, but here is how I got it to work in
one of our little applications....
C#:
class Program
{
// ready the validation DLL for use
[DllImport("DocVal.dll")]
public static extern String DllMain(string path);
static void Main(string[] args)
{
try
{
// lannch our C++ DLL with the fully qualified path to the
document
String response =
DllMain(@"\\share\SharedDocs\test\Sometext.txt");
Console.WriteLine("Validation response is: " + response);
}
catch (Exception exec)
{
Console.WriteLine("There was an internal error with the DLL
:-( Details: " + exec.Message);
}
}
-----------------------
in C++: ( I choose to make a new dll project in the editor)
.....normal header stuff ....
#pragma data_seg("SharedBlockOMemory")
// shared stuff here... (if needed)
#pragma data_seg()
// these are the functions we can call outside of our DLL if need be
extern LPCSTR _declspec(dllexport) DllMain(char * pathToFile);
LPCSTR _declspec(dllexport) DllMain(char * pathToFile)
{
char inputFile[255]; // our input .txt file
bool verboseMode = false; // to keep track if we want everything
logged verbosely
bool ignoreFileExtension = false; // to see if we are to ignore the file
extension
sprintf(inputFile, "%s\0", pathToFile); // and store it into a char[]
inputFileCString = pathToFile; // assign this to a CString for use later
// ... your work here...
return /*(something in LPCSTR format)*/ "Hello!";
} // end DllMain ()
Note that you may have trouble using CStrings in your C++ code... I had to
take almost all of them out when I converted some of our stuff to dlls...
expecially CString return types from calling any functions within your C
code. I used char *'s and that seemed to work well.
Hope this gets you started...
Rob K