Hai....
i have Vc++ code . i need to create Dll file by using following code
can u help me....here with this i had sent my vc++ code -
VARIANT root[64] = {0}; // Generic IDispatchs
-
VARIANT parm[64] = {0}; // Generic Parameters
-
VARIANT rVal = {0}; // Temporary result holder
-
int level=0; // Current index into root[]
-
-
// Initialize the OLE Library...
-
OleInitialize(NULL);
-
-
// Line 1: dim app as object
-
VARIANT app = {0};
-
-
// Line 2: set app = createobject Excel.Application
-
{
-
CLSID clsid;
-
CLSIDFromProgID(L"Excel.Application", &clsid);
-
HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER, IID_IDispatch, (void **)&rVal.pdispVal);
-
if(FAILED(hr)) {
-
char buf[256];
-
sprintf(buf, "CoCreateInstance() for \"Excel.Application\" failed. Err=%08lx", hr);
-
::MessageBox(NULL, buf, "Error", 0x10010);
-
_exit(0);
-
}
-
rVal.vt = VT_DISPATCH;
-
}
-
VariantCopy(&app, &rVal);
-
VariantClear(&rVal);
-
-
// Line 3: app . visible = 1
-
rVal.vt = VT_I4;
-
rVal.lVal = 1;
-
VariantCopy(&root[++level], &app);
-
AutoWrap(DISPATCH_PROPERTYPUT, NULL, root[level].pdispVal, L"visible", 1, rVal);
-
VariantClear(&root[level--]);
-
VariantClear(&rVal);
-
-
// Line 4: app . workbooks . add
-
VariantCopy(&root[++level], &app);
-
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &root[level+1], root[level++].pdispVal, L"workbooks", 0);
-
AutoWrap(DISPATCH_METHOD, NULL, root[level].pdispVal, L"add", 0);
-
VariantClear(&root[level--]);
-
VariantClear(&root[level--]);
-
-
// Line 5: MsgBox Slow fill example...
-
::MessageBox(NULL, "Slow fill example...", "MsgBox", MB_SETFOREGROUND);
-
-
// Line 6: dim i as long
-
VARIANT i = {0};
-
-
// Line 7: dim j as long
-
VARIANT j = {0};
-
-
// Line 8: with app . activesheet
-
VariantCopy(&root[++level], &app);
-
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal, root[level].pdispVal, L"activesheet", 0);
-
VariantClear(&root[level--]);
-
VariantCopy(&root[++level], &rVal);
-
VariantClear(&rVal);
-
-
// Line 9: for i = 1 to 15
-
{
-
long endVali = 15;
-
i.vt = VT_I4;
-
for(i.lVal=1; i.lVal<=endVali; i.lVal++) {
-
-
// Line 10: for j = 1 to 15
-
{
-
long endValj = 15;
-
j.vt = VT_I4;
-
for(j.lVal=1; j.lVal<=endValj; j.lVal++) {
-
-
// Line 11: . cells i , j . value = i
-
VariantCopy(&rVal, &i);
-
VariantCopy(&parm[0], &i);
-
VariantCopy(&parm[1], &j);
-
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &root[level+1], root[level++].pdispVal, L"cells", 2, parm[1], parm[0]);
-
VariantClear(&parm[0]);
-
VariantClear(&parm[1]);
-
AutoWrap(DISPATCH_PROPERTYPUT, NULL, root[level].pdispVal, L"value", 1, rVal);
-
VariantClear(&root[level--]);
-
VariantClear(&rVal);
-
-
// Line 12: DoEvents
-
{
-
MSG msg;
-
while(PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)) {
-
TranslateMessage(&msg);
-
DispatchMessage(&msg);
-
}
-
}
-
-
// Line 13: next j
-
}
-
}
-
-
// Line 14: next i
-
}
-
}
-
-
// Line 15: msgbox Click me to clear range
-
::MessageBox(NULL, "Click me to clear range", "MsgBox", MB_SETFOREGROUND);
-
-
// Line 16: . range A1:O15 . Clear
-
parm[0].vt = VT_BSTR; parm[0].bstrVal = ::SysAllocString(L"A1:O15");
-
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &root[level+1], root[level++].pdispVal, L"range", 1, parm[0]);
-
VariantClear(&parm[0]);
-
AutoWrap(DISPATCH_METHOD, NULL, root[level].pdispVal, L"Clear", 0);
-
VariantClear(&root[level--]);
-
-
// Line 17: end with
-
VariantClear(&root[level--]);
-
-
// Line 18: msgbox Now the fast way!
-
::MessageBox(NULL, "Now the fast way!", "MsgBox", MB_SETFOREGROUND);
-
-
// Line 19: dim arr 1 to 15 , 1 to 15 as long
-
VARIANT arr;
-
arr.vt = VT_ARRAY | VT_VARIANT;
-
{
-
SAFEARRAYBOUND sab[2];
-
sab[0].lLbound = 1; sab[0].cElements = 15-1+1;
-
sab[1].lLbound = 1; sab[1].cElements = 15-1+1;
-
arr.parray = SafeArrayCreate(VT_VARIANT, 2, sab);
-
}
-
-
// Line 20: for i = 1 to 15
-
{
-
long endVali = 15;
-
i.vt = VT_I4;
-
for(i.lVal=1; i.lVal<=endVali; i.lVal++) {
-
-
// Line 21: for j = 1 to 15
-
{
-
long endValj = 15;
-
j.vt = VT_I4;
-
for(j.lVal=1; j.lVal<=endValj; j.lVal++) {
-
-
// Line 22: arr i , j = i
-
VariantCopy(&rVal, &i);
-
{
-
VARIANT tmp = {0};
-
long indices[] = {i.lVal,j.lVal};
-
VariantCopy(&tmp, &rVal);
-
SafeArrayPutElement(arr.parray, indices, (void*)&tmp);
-
}
-
VariantClear(&rVal);
-
-
// Line 23: next j
-
}
-
}
-
-
// Line 24: next i
-
}
-
}
-
-
// Line 25: app . activesheet . range A1:O15 . value = arr
-
VariantCopy(&rVal, &arr);
-
VariantCopy(&root[++level], &app);
-
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &root[level+1], root[level++].pdispVal, L"activesheet", 0);
-
parm[0].vt = VT_BSTR; parm[0].bstrVal = ::SysAllocString(L"A1:O15");
-
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &root[level+1], root[level++].pdispVal, L"range", 1, parm[0]);
-
VariantClear(&parm[0]);
-
AutoWrap(DISPATCH_PROPERTYPUT, NULL, root[level].pdispVal, L"value", 1, rVal);
-
VariantClear(&root[level--]);
-
VariantClear(&root[level--]);
-
VariantClear(&root[level--]);
-
VariantClear(&rVal);
-
-
// Line 26: msgbox All done.
-
::MessageBox(NULL, "All done.", "MsgBox", MB_SETFOREGROUND);
-
-
// Line 27: app . activeworkbook . saved = 1
-
rVal.vt = VT_I4;
-
rVal.lVal = 1;
-
VariantCopy(&root[++level], &app);
-
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &root[level+1], root[level++].pdispVal, L"activeworkbook", 0);
-
AutoWrap(DISPATCH_PROPERTYPUT, NULL, root[level].pdispVal, L"saved", 1, rVal);
-
VariantClear(&root[level--]);
-
VariantClear(&root[level--]);
-
VariantClear(&rVal);
-
-
// Line 28: app . quit
-
VariantCopy(&root[++level], &app);
-
AutoWrap(DISPATCH_METHOD, NULL, root[level].pdispVal, L"quit", 0);
-
VariantClear(&root[level--]);
-
-
// Line 29: set app = nothing
-
VariantClear(&app);
-
-
// Clearing variables
-
VariantClear(&app);
-
VariantClear(&i);
-
VariantClear(&j);
-
VariantClear(&arr);
-
-
// Close the OLE Library...
-
OleUninitialize();
2 3438 sicarie 4,677
Recognized Expert Moderator Specialist
That's a lot of interesting code there.
Did you have a question about it? Is it creating an error? What's the relevance of the code to your dll issue? Have you searched how to make a dll in VC++?
Banfa 9,065
Recognized Expert Moderator Expert
Well start by creating a DLL project in MSVC (VC++). This will create the basic file structure and compile and link options you need.
Then add a function with your code in it including the additional function type modifiers require for a DLL function (defined in the symbol DLL_EXPORT I believe).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ariant |
last post by:
Hi -
I'm trying to query my database to find the min, max and average times
(in seconds, or minutes, or something) between two timestamps. I've
tried using:
Select avg(timestamp1 - timestamp2) from table;
I get an error saying that avg() expects a number, not an interval.
Is there a way (in a SQL stmt) to convert timestamps (or their
|
by: soni29 |
last post by:
hi,
i need some help with a query, also to find out if this is even
possible with sql. currently i have a table with the following data:
CustomerNumber CustomerBranch
123 NULL
123 1
123 2
221 NULL
221 5
|
by: Anonymous |
last post by:
I'm trying to port code from VC.net to VC.net 2003. Here's a typical
piece of code that's often used:
template<class T> class PseudoContainer {
typedef T::iterator iterator; // this line will change in the next
example...
};
|
by: Jed |
last post by:
Hello to all!
I have a couple of projects I intend starting on, and was wondering if
someone here could make a suggestion for a good compiler and development
environment.
My goals are as follows:
1. Develop the project code on XP.
|
by: Tatu Portin |
last post by:
Have this kind of struct:
typedef struct {
char **user_comments;
/* ... */
} vorbis_comment;
/* prototype */
char * read_vorbis_string
( FILE *sc);
| |
by: Anthony Gallagher |
last post by:
I have a bunch of libraries compiled using VC++ 6.0, and I am trying to
recompile one of our projects using VC++ .NET. I get all kind of linker
errors (specially in STL calls). How do I get rid of these errors??
Anthony
|
by: Sai Kit Tong |
last post by:
In the article, the description for
"Modiy DLL That Contains Consumers That Use Managed Code and DLL Exports
or
Managed Entry Points"
suggests the creation of the class ManagedWrapper.
If I need to build multiple mixed mode dll's used by a consumer application,
do I have to implement multiple ManagedWrapper's (each embedded in
indiviudal DLL project) and call all of them in my consumer application?
|
by: ashish.sadanandan |
last post by:
Hi,
Can someone please tell me where I can find those two libraries for
Visual C++ 2005 Express Edition compiler?
Thanks in advance,
Ashish.
|
by: rsadalarasu |
last post by:
Hi Everybody,
I m very new to Db2. I tried compiling a stored procedure in DB2 Development Center. Build failed with error message like nmake command is unavailable..(something like that). I came to know that Db2 8.1 need VC++ to be installed to compile a stored procedure.
Now the problem is I dont have VC++ installed in my machine. I need to compile the stored proc desperately. But some how i got the installed version of VC++ from...
|
by: Norman Diamond |
last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet
Framework 2. Options are set in the setup project properties, so if these
two dependencies are not already installed then this installer will install
them.
But what about the situation where VC runtime has already been installed?
In fact it's been installed twice. Although the project was built on a
Windows XP system with Visual Studio 2005 SP1 and the results were...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |