Home > Software engineering >  About how to use VC call VB to write a DLL
About how to use VC call VB to write a DLL

Time:10-09

Everybody is good, the younger brother for the first time I post, please a lot of help,
Playing with a device in the past two days, want to call the device of the DLL in the SDK, the use of the SDK documentation is written in VB, the DLL that which is written by VB, because I use VIEWDLL to look at the DLL, he couldn't find a said the method of function in the SDK documentation, please help to behold a great god had done in the VC call written by VB DLL experience, teach the younger brother, thank you very much!!!!!!

CodePudding user response:


As shown in figure is I see the contents of this DLL from viewdll, thank you!

CodePudding user response:

This is a look at the standard COM components export function, so want to use the DLL in COM ways, in the VC with import statements to import the type library, the compiler will help you generate COM interface c + + header files and wrapper class, you directly use the wrapper class in c + +

CodePudding user response:

Typical COM components leads to the four functions

CodePudding user response:

This is a COM component in the MFC class wizard in addtypelib should be able to create a new class in the VC, and then you can call

CodePudding user response:

Still not clear how to refer to it, thank you:)

CodePudding user response:

2 and 4 floors, can be used in VC after import

CodePudding user response:

There is still people using vb to online? VB6.0 by use?
VS2003 starting around is vb.net,,,

CodePudding user response:

refer to 7th floor fly4free response:
online vb to others? VB6.0 by use?
VS2003 starting around is vb.net,,,

The use of the equipment example, normal phenomenon

CodePudding user response:

http://cppblog.com/woaidongmao/archive/2011/01/10/138250.html

CodePudding user response:

Fyi:
//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 Office97 in
//the Compile with cl/GX comexcel. CPP
//TO DO: Edit the # import paths
//# pragma message (" Make sure you go to view the Options. The Directories and add the paths to mso97. DLL and vbeext1. The olb. Mso97. DLL will usually be a c: \ \ \ "\ Program Files \ Microsoft Office " \ \ \ "" \ \ Office, and vbeext1. The olb will be in c: \ \ " \ Program Files \ \ \ \ "" Common Files " \ \ \ "Microsoft Shared \ \ " VBA ")
# import "C: \ \ Program Files \ \ Common Files \ \ Microsoft Shared \ \ Office11 \ \ the oledata.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 (of which: 4192 4146)

# include & lt; Stdio. H>
# include & lt; Tchar. H>

Void dump_com_error (_com_error & amp; E)
{
_tprintf (_T (" Oops - hit an error! \ n "));
_tprintf (_T (" \ \ a tCode=% 08 lx \ n "), e.E rror ());
_tprintf (_T (" \ \ a tCode fancy=% s \ n "), e.E rrorMessage ());
_bstr_t bstrSource (e.S ource ());
_bstr_t bstrDescription (e.D escription ());
_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 the namespace Excel;

_ApplicationPtr pXL;

Try
{
PXL. CreateInstance (L "Excel. Application");

The pXL - & gt; The Visible=VARIANT_TRUE;

WorkbooksPtr pBooks=pXL - & gt; Workbooks.
_WorkbookPtr pBook=pBooks - & gt; Add ((long) xlWorksheet);
_WorksheetPtr pSheet=pXL - & gt; ActiveSheet.

RangePtr pRange.
PRange=pSheet - & gt; Range [A21 "];
PRange - & gt; Value2=75 l;
//pRange - & gt; NumberFormatLocal="@".

_CommandBarsPtr pCmdbars=pXL - & gt; CommandBars;
Int iCmdbars=pCmdbars - & gt; GetCount ();

Sleep (1000);
PRange=pSheet - & gt; Range (" he "),
PRange - & gt; Insert ((long) Excel: : xlDown);
PRange - & gt; Merge ();

Sleep (1000);

PBook - & gt; Saved=VARIANT_TRUE;
The pXL - & gt; The Quit ();
}
The catch (_com_error & amp; E)
{
Dump_com_error (e);

The pXL - & gt; The Quit ();
}
}


CodePudding user response:

Thank you for your attention! Answer is very detailed!
  • Related