2009-08-21 3 views
1

저는 ScreenCameraSDK가 있고 11kb dll 파일이 있습니다. 사용할 수있는 기능을 나열한 설명서도 있습니다. 그것은vC++ win32 프로젝트에서 activex dll을 사용합니다.

ScreenCamera SDK 액티브 참조 문서를 말한다
액티브 참조

시스템의 액티브 ID는 다음과 같습니다 ScreenCameraSDK.RemoteControl
수익이 FAIL 인터페이스 또는 성공에 모든 방법. (0 또는 1).
응용 프로그램에서 ActiveX의 인스턴스를 만든 다음 InitializeScreenCameraRemoteControl을 호출하십시오. 반환 값이 SUCCESS이면 ScreenCamera가 제대로 설치되고 ActiveX 인터페이스에서 다른 메서드를 호출 할 수 있습니다. ScreenCamera를 찾을 수 없으며 지원팀에 문의해야합니다. **

이제 내 질문에 dll과 다른 파일이 있습니다. 어떻게하면 내가 다음 코드를 시도했지만 미정 식별자를 컴파일 오류가 발생했습니다

#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 알 수 말한다 비주얼 스튜디오 2008 감사

을 VC++ 프로젝트에 내부의 기능을 사용할 수 있습니다!

답변

0

우선이 작업은 #import 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에 대한 핸들은 어디에 있습니까? –

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

관련 문제