2009-08-21 11 views
1

私はScreenCameraSDKを持っていて、11kbのDLLファイルが付属しています。 ScreenCameraSDK.RemoteControl
はFAILを返しインターフェイスまたはSUCCESS上のすべての方法:これは、システム上のActiveX IDがあるvC++ win32プロジェクトでactivex dllを使用しています

ScreenCamera SDKのActiveXリファレンスドキュメント
ActiveXリファレンス

言います。 (0または1)。
アプリケーションでActiveXのインスタンスを作成し、InitializeScreenCameraRemoteControlを呼び出します。戻り値がSUCCESSの場合、ScreenCameraが正しくインストールされているため、ActiveXのインターフェース上で他のメソッドを呼び出すことができます。 ScreenCameraが見つからない場合、サポートに連絡する必要があります。**

私の質問は、dllとその他のファイルがあります。どのように私は、次のコードを試みたが、未定義の識別子コンパイルエラーをGOT

#include <stdio.h> 

     // This is the path for your DLL. 
     // Make sure that you specify the exact path. 

     #import "e:\ScreenCameraSDK.dll" no_namespace 

     void main() 
     { 
     BSTR bstrDesc; 

     try 
     { 
     CoInitialize(NULL); 
     short st = 2; 
     short st1; 
     // Declare the Interface Pointer for your Visual Basic object. Here, 
     // _Class1Ptr is the Smart pointer wrapper class representing the 
     // default interface of the Visual Basic object. 

     _Class1Ptr ptr; 
     // Create an instance of your Visual Basic object, here 
     // __uuidof(Class1) gets the CLSID of your Visual Basic object. 

     ptr.CreateInstance(__uuidof(Class1)); 
     st1 = ptr->MyVBFunction(&st); 
     } 
     catch(_com_error &e) 
     { 
     bstrDesc = e.Description(); 

     } 
     CoUninitialize(); 
     } 

はそれが_Class1Ptrが不明であると言うのVisual Studioで2008 おかげ

をVC++プロジェクトでは、その中の機能を使用することができます!

答えて

0

まず、これを行う必要があります#dllをインポートすると、コンパイラは必要なすべての定義を自動的に生成します。次に、スマートポインタ、またはCreateInstance()を使用して、ライブラリからオブジェクトを作成します。

#import "C:\files\test.dll" no_namespace rename("EOF", "EOFile") 

... 
int main() { 
    if (FAILED(::CoInitialize(NULL))) 
     return 0; 
    ........ 
    ::CoUninitialize(); 
    return 0; 
} 
+0

あなたは、より正確な例を与えることができますか?ここでインポートされたDLLのハンドルはどこですか?名前空間stdを使用して –

2
BSTR bstrDesc; 

try 
{ 
    HRESULT hr= CoInitialize(NULL); 
    CLSID clsid; 
    hr = CLSIDFromProgID(OLESTR("<complete class name as see in registry>"),&clsid); 
    short st = 2; 
    short st1; 

//nameOfClassInOCX is placeholder for explanation. If you OCX com class name is blabla 
    //use _blabla and so on. 

    _nameOfClassInOCX * ptr; 

    hr = CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_nameOfClassInOCX),(LPVOID*)&ptr); 

    cout << ptr->GetFees("hi") <<endl; 
    ptr->Release(); 
} 
catch(_com_error &e) 
{ 
     bstrDesc = e.Description(); 
} 

CoUninitialize(); 
+0

の#include "stdafx.hを" の#include の#include の#include "stdio.hの" 。 – purvin

関連する問題