在vc6中使用C#DLL

时间:2013-06-17 12:45:14

标签: c# c++ visual-c++ dll vc6

我有一个c#dll我可以在vc.net(VS2010)中调用它,当我尝试运行在VC6中运行相同的源代码时它会出错

 IMyTestDLLPtr pIMYTESTDLL(__uuidof(CMYTestDLL)); 

以下是这个小实用程序的完整代码

#include "stdafx.h"
#include <iostream>

// Import the type library in DLL
#import  "MY.TestDLL.tlb" raw_interfaces_only

using namespace My_TestDLL;
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
   // Initialize the COM interface
   HRESULT hr = CoInitialize(NULL);
   // Make a smart pointer to the EPASS interface in DLL
   IMyTestDLLPtr pIMYTESTDLL(__uuidof(CMYTestDLL));  



   // Pass Params to API  
   BSTR result = 0;
   hr = pIMYTESTDLL->DLLFunction(1, _bstr_t("11111111111"),  &result);


   CoUninitialize();
   // Display the results
   cout << result << '\n';  
   return 0;
}

任何人请帮助我如何在vc6中使用它

0 个答案:

没有答案