大家好,小弟我第一次發貼,請多多幫忙。
這兩天在玩一個設備,想呼叫那個設備的SDK里的DLL,那個sdk的使用說明檔案里都寫的是VB的東西,它的DLL看起來也是VB寫的,因為我用VIEWDLL去看那個dll,根本找不到有他SDK說明檔案里說的那些method函式,請幫忙看哪位大神有做過在VC里呼叫過VB寫的DLL的經驗,教教小弟,多謝了!!!
uj5u.com熱心網友回復:

如圖是我從viewdll里看到的這個dll的內容,謝謝!
uj5u.com熱心網友回復:
這個一看就是標準COM組件的匯出函式,所以要用COM的方式來使用DLL,在VC里要用import陳述句匯入型別庫,編譯器會幫你生成COM介面的C++頭檔案和封裝類,你在C++里直接使用這些封裝類即可uj5u.com熱心網友回復:
典型的COM組件就匯出這4個函式uj5u.com熱心網友回復:
這個是 COM 組件 ,在 mfc class wizard 中 addtypelib 應該可以 在 VC 中新建一個類,然后就可以呼叫了uj5u.com熱心網友回復:
還是沒有弄清楚該怎么參考它,先謝謝大家了:)uj5u.com熱心網友回復:
2、3、4樓,匯入后就可以在VC中用了uj5u.com熱心網友回復:
在線還有人用vb呢? VB6.0 ?VS2003 左右開始就是 vb.net 了。。。
uj5u.com熱心網友回復:
設備的使用方法例子,正常現象
uj5u.com熱心網友回復:
http://cppblog.com/woaidongmao/archive/2011/01/10/138250.htmluj5u.com熱心網友回復:
僅供參考:// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Visual C++ Language Reference and related
// electronic documentation provided with Microsoft Visual C++.
// See these sources for detailed information regarding the
// Microsoft Visual C++ product.
// NOTE: This example will only work with Excel8 in Office97
// Compile with cl /GX comexcel.cpp
// TO DO: Edit the #import paths
//#pragma message ("Make sure you go to Tools.Options.Directories and add the paths to mso97.dll and vbeext1.olb. Mso97.dll will usually be in c:\\\"Program Files\"\\\"Microsoft Office\"\\Office, and vbeext1.olb will be in c:\\\"Program Files\"\\\"Common Files\"\\\"Microsoft Shared\"\\VBA")
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\Office11\\mso.dll" no_namespace rename("DocumentProperties", "DocumentPropertiesXL")
#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\VBA6\\VBE6EXT.OLB" no_namespace
#import "C:\\Program Files\\Microsoft Office\\OFFICE11\\excel.exe" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") rename("DocumentProperties", "DocumentPropertiesXL") no_dual_interfaces
#pragma warning (disable:4192 4146)
#include <stdio.h>
#include <tchar.h>
void dump_com_error(_com_error &e)
{
_tprintf(_T("Oops - hit an error!\n"));
_tprintf(_T("\a\tCode = %08lx\n"), e.Error());
_tprintf(_T("\a\tCode meaning = %s\n"), e.ErrorMessage());
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
_tprintf(_T("\a\tSource = %s\n"), (LPCTSTR) bstrSource);
_tprintf(_T("\a\tDescription = %s\n"), (LPCTSTR) bstrDescription);
}
// If this is placed in the scope of the smart pointers, they must be
// explicitly Release(d) before CoUninitialize() is called. If any reference
// count is non-zero, a protection fault will occur.
struct StartOle
{
StartOle() { CoInitialize(NULL); }
~StartOle() { CoUninitialize(); }
} _inst_StartOle;
void main()
{
using namespace Excel;
_ApplicationPtr pXL;
try
{
pXL.CreateInstance(L"Excel.Application");
pXL->Visible = VARIANT_TRUE;
WorkbooksPtr pBooks = pXL->Workbooks;
_WorkbookPtr pBook = pBooks->Add((long)xlWorksheet);
_WorksheetPtr pSheet = pXL->ActiveSheet;
RangePtr pRange;
pRange = pSheet->Range["A21"];
pRange->Value2 = 75L;
//pRange->NumberFormatLocal = "@";
_CommandBarsPtr pCmdbars = pXL->CommandBars;
int iCmdbars = pCmdbars->GetCount();
Sleep(1000);
pRange = pSheet->Range["20:20"];
pRange->Insert( (long)Excel::xlDown );
pRange->Merge();
Sleep(1000);
pBook->Saved = VARIANT_TRUE;
pXL->Quit();
}
catch(_com_error &e)
{
dump_com_error(e);
pXL->Quit();
}
}
uj5u.com熱心網友回復:
謝謝各位!回答的確實很詳細!轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/123976.html
上一篇:怎么簡單的添加按鈕背景顏色?
