|
No that's not it.
My problem is to write a function that will take multiple types of arguments simulatneously:
eg: some_function(int arg1, float arg2, ...)
obviously the function call can have any permutation of arguments, and any number of arguments at the same time.
I need this because I am writing a function that will be able to call any function in a DLL when the user provides the name of the DLL, the name of the function and the type and number of parameters
So you see I have to write a generic function.
|
|
|
|
|
The easiest way to do this is by utilizing VARIANTS and CComVariant too!
#include < atlbase.h >
#include < stdio.h >
//------------------------------------------
void TypeArgument(const CComVariant vtArg)
//------------------------------------------
{
switch (vtArg.vt)
{
case VT_I4 :
wprintf(L"Integer Arg = %d\r\n",vtArg.lVal);
break;
case VT_BSTR:
wprintf(L"string Arg = %s\r\n",vtArg.bstrVal);
break;
case VT_EMPTY:
wprintf(L"Empty(void) Arg\r\n");
break;
default:
printf("unhandled type = %d\r\n", vtArg.vt);
break;
}
}
//------------------------------------------
BOOL AnyArguments(CComVariant vtFirst, ...)
//------------------------------------------
{
va_list vargs;
CComVariant varArg;
va_start(vargs, vtFirst);
TypeArgument(vtFirst);
while (TRUE)
{
varArg = va_arg( vargs, CComVariant);
if (varArg.vt == VT_ERROR || varArg.vt == VT_EMPTY)
break;
TypeArgument(varArg);
varArg.vt = VT_EMPTY;
}
va_end(vargs);
return TRUE;
}
//------------------------------------------
void Test()
//------------------------------------------
{
AnyArguments(CComVariant("Ali"), CComVariant(1), CComVariant(2.3));
AnyArguments(CComVariant());
}
int main()
{
Test();
return 0;
}
Even though you were able to get any combination of parameters, I don't beleive you can call any function in a DLL with that!! You need to use assembly code to be able to do that!
If you succeeded with this, please let's know so we can share the knowledge
Good luck!
Mh2!
|
|
|
|
|
Yes you are right. We used assembly code to push all the arguments onto the stack and then push the function pointer (returned by GetProcAddress) and then call the function from withing assembly code and finally pop the stack to retrieve the return value.
|
|
|
|
|
The question is somewhat confusing. By taking arguments from the user do you mean.
1) Reading program parameters from the command line.
2) Interpretting variable arguments passed to a subroutine from the caller.
3) Prompting for values to be put in.
Various respondants seem to have interpretted it various ways. I guess 1)
You'll probably loop through the parameters one by one. For each one you can try
various conversions. The simplest way is probably to use sscanf. Try a format string like
"%i%c" (tries to read the extra character to ensure the whole string was an integer).
If it's not an integer try for a float.
If it's not a float then treat is as a string.
What you do with the arguments then really depends on the object of the excercise.
You could, if you wanted, store them in a structure like --
struct myArg {
short int type;
union {
float f_val;
int i_val;
char *string_val;
}
};
|
|
|
|
|
Hi all,
Can anyone tell me where I can get some example source code for class template. for example, deque, vector source code...
Thank you
|
|
|
|
|
THE book to buy is STL Tutorial and Reference Guide by David R. Musser, et al. Foreward by Alexander Stepanov ( who wrote the STL ).
I know you're looking for a download, but if you're serious about it you probably should buy this book.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
You might want to take a look at www.stlport.org which is what I use. This is an implementation of the C++ STL. There is quite a bit to wade through, but it works quite well.
|
|
|
|
|
Does anyone know how to create a file name that has the date & time as the file name?
Thanks
|
|
|
|
|
Have a look at the localtime function. Combining time() with this and sprintf will do what you want. It has worked for me in past.
|
|
|
|
|
Thanks Rick for your help. It all works now.
|
|
|
|
|
Is there is any one who can help me to find the way so that i can persist the data in xml file on the client side after requesting it from server in a xml file before displaying it into web browser and then i can use it for later requests
Shahzad Ahmad
|
|
|
|
|
Universe Technology is just starting out and is looking for programmers. If you have skill in ASP, VBSCRIPT, HTML, Java, JavaScript, C++, C, XML or any other programming language of substance, please send me an e-mail at Alexjfink@aol.com, I will look into each applicant personally, if we like what we see, we will tell you more about Universe Technology.
|
|
|
|
|
Does anyone know how to attach IE style toolbars to a tab control, to create a toolbar similar to that of 3dsMax3.
I am able to attach toolbars to the main window, but have had no success in attaching them to dialogs or tab controls.
Is this possable?
Ant
|
|
|
|
|
Dear all,
I 'm working with a project that involved to manipulate ActiveX control from another thread in multi-thread application, but I don't know how.
Can any-body help me?
My email address: bhkien@vnuh.edu.vn
Thanks,
|
|
|
|
|
Dear all,
I 'm working with a project that involved to manipulate ActiveX control from another thread in multi-thread application, but I don't know how.
Can any-body help me?
Contact me following: bhkien@vnuh.edu.vn
Thanks,
|
|
|
|
|
Hello everyone,
I am trying to display the content that is too large for a window (CWnd derived class). So I need to implement the scrolling functionality.I dont want to use the built-in MFC view classes as i am not using DV- arch. Can any one help me out about how to implement the scrolling?
Also can any one let me know about 'clipping' & its implications & implementation?
thanks,
Mangesh
|
|
|
|
|
i'm doing project to store sound files and send it to other computers any one who know about this topic please email to me
|
|
|
|
|
Can some one brief ma abt callback() function and just explain me with a small example
otherwise please point me to some place where i can get acquinted with this function
thanks
chandu
|
|
|
|
|
// The callback function type
typedef void StepProc();
// the callback function
void Step()
{
cout << ".";
}
void DoSteps(StepProc* pProc)
{
for (int i = 0; i < 10; i++)
{
(*pProc)();
}
}
void TestCallback()
{
//Call DoSteps() with ::Step as the argument
::DoSteps(::Step);
}
Michael S. Scherotter
Lead Software Architect
Tartus Development, Inc.
|
|
|
|
|
Hi,
I have just 1 question: how to create a raw socket with incapsulated UDP protocol; also I need to set up some parameters, like IP and port.
Best regards,
Dmitry
|
|
|
|
|
also I need to set up some parameters, like IP and port.
And what can I say, now?
?
?
?
-------
Nature, to be commanded, must be obeyed. (Francis Bacon)
Nature, to be apprehended, must be obeyed. (Ayn Rand)
|
|
|
|
|
How to connect to the Oracle 8i database using only C (normal) without the external options
Karajagi Prashant R.
|
|
|
|
|
These are the steps breifly
u can try out this and let me know
i)Include “sql.h”
ii)SQLAllocHandle()
iii)SQLSetAttrib
iv)SQLConnect
v)SQLDisconnect
vi)SQLFreeHandle
chandu
|
|
|
|
|
Is there any way besides using a right-reading locale to make windows with scrollbars on the left and top instead of on the right and bottom?
Michael S. Scherotter
Lead Software Architect
Tartus Development, Inc.
|
|
|
|
|
I have developed an ActiveX Control using ATL, Now, I want to add drag & drop functionality in this control to drag text values. I have tried MSDN DnDZoom example but couldn't make much progress. I want someone to help me in implementing this functionality or pointing me to right direction with code example. I am uregently in need of this.
Tushar Bhatt
|
|
|
|