|
haha, so I did. I have no excuse, the 'S' and 'M' are too far apart to blame the keyboard. So, if anybody ask's, it was the wife
|
|
|
|
|
Hi,
Somebody has example on how calling managed (C#) DLL from unmanaged code (VC++ 6) ? I need it for backward compatibility reason.
Thanks before.
|
|
|
|
|
write a regular DLL in managed C++
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
Any direct link or reference in easier language, pls ? Your blog is half chinese and unfortuantely I don't understood any single letter of it.
Thanks anyway
|
|
|
|
|
|
Hi,
i made a MFC ActiveX Control with Visual Studio 2005!
i just take the default MFC ActivX Control Project!
than i added 3 methodes:
long CActiveX_ControlCtrl::Add(long x, long y);<br />
long CActiveX_ControlCtrl::Sub(long x, long y);<br />
void CActiveX_ControlCtrl::ViewResult(void);
than i read this article:
http://msdn2.microsoft.com/en-us/library/95357zak(vs.80).aspx
i manually added the methods in the DISPATCH_MAP:
------------------------------------------------
BEGIN_DISPATCH_MAP(CActiveX_ControlCtrl, COleControl)<br />
DISP_FUNCTION_ID(CActiveX_ControlCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)<br />
<br />
DISP_FUNCTION(CActiveX_ControlCtrl, "Add", Add, VT_R4, VTS_R4 VTS_R4)<br />
DISP_FUNCTION(CActiveX_ControlCtrl, "Sub", Sub, VT_R4, VTS_R4 VTS_R4)<br />
DISP_FUNCTION(CActiveX_ControlCtrl, "ViewResult", ViewResult, VT_EMPTY, VTS_NONE)<br />
<br />
END_DISPATCH_MAP()
and 4 lines are added to the control's .IDL:
--------------------------------------------
[ uuid(1103A7D0-19C1-41B5-9EE3-090B71B9ECFF),<br />
helpstring("Dispatch interface for ActiveX_Control Control")]<br />
dispinterface _DActiveX_Control<br />
{<br />
properties:<br />
methods:<br />
<br />
[id(DISPID_ABOUTBOX)] void AboutBox();<br />
[id(1)] long Add(long x, long y);<br />
[id(2)] long Sub(long x, long y);<br />
[id(3)] void ViewResult(void);<br />
};
the implementation of the methode Add:
--------------------------------------
long CActiveX_ControlCtrl::Add(long x, long y)<br />
{<br />
int result = x + y;<br />
stringstream str1;<br />
str1 << x;<br />
MessageBox(str1.str().c_str() , "info");<br />
return result;<br />
}<br />
when i test the activX control with ActiveX Control Test Container the Messagebox show the value "1073741824" when i call the methode with add(3, 3);
hm, any idea?
greets surf
|
|
|
|
|
Try this
long CActiveX_ControlCtrl::Add(long x, long y)
{
int result = x + y;
CString strMsg;
strMsg.Format("%i", result);
MessageBox(strMsg, "info");
return result;
}
Or this
long CActiveX_ControlCtrl::Add(long x, long y)
{
int result = x + y;
char szBuff[20];
itoa(result, szBuff, 10);
MessageBox(szBuff, "info");
return result;
}
-- modified at 11:41 Tuesday 28th March, 2006
|
|
|
|
|
i found the problem;)
i changed my code to:
dispinterface _DActiveX_Control<br />
{<br />
properties:<br />
methods:<br />
<br />
[id(DISPID_ABOUTBOX)] void AboutBox();<br />
[id(1)] long Add(long x, long y);<br />
[id(2)] long Sub(long x, long y);<br />
[id(3)] void ViewResult(void);<br />
BEGIN_DISPATCH_MAP(CActiveX_ControlCtrl, COleControl)<br />
DISP_FUNCTION_ID(CActiveX_ControlCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)<br />
<br />
DISP_FUNCTION_ID(CActiveX_ControlCtrl, "Add", 1, Add, VT_I4, VTS_I4 VTS_I4)<br />
DISP_FUNCTION_ID(CActiveX_ControlCtrl, "Sub", 2, Sub, VT_I4, VTS_I4 VTS_I4)<br />
DISP_FUNCTION_ID(CActiveX_ControlCtrl, "ViewResult", 3, ViewResult, VT_EMPTY, VTS_NONE)<br />
<br />
END_DISPATCH_MAP()
any idea why i cant take the DISP_FUNCTION like before?
cu
|
|
|
|
|
VTS_R4 is a float, VTS_I4 is a long. doesn't match your function definition. I didn't notice that before.
You should use the wizard & class view this is alot easier
-- modified at 14:13 Tuesday 28th March, 2006
|
|
|
|
|
You should use the wizard & class view this is alot easier ... but how can i call the wizard??????
i only can use CActiveX_ControlCtrl - Add - Add Function than i see the Add Member Function Wizard!
but i manually have to add the definition in the Dispatch map... and the definition in [ uuid(1103A7D0-19C1-41B5-9EE3-090B71B9ECFF),
helpstring("Dispatch interface for ActiveX_Control Control")]
dispinterface _DActiveX_Control
{
properties:
methods:
[id(DISPID_ABOUTBOX)] void AboutBox();
[id(1)] long Add(long x, long y); <---------------------------
right?
i use visual studio 2005!!!
cu
|
|
|
|
|
No your clicking on the actual class. Go to your interface node in the tree and right click and Add --> Add Method... It will generate everything for you.
|
|
|
|
|
ahhh;)
u mean:
ActiveX_ControlLib - _DActiveX_Control - Add Method...
what if i need a variable?
i got to C_ActiveX_ControlCtrl - Add Variable right?
cu
|
|
|
|
|
Yes & Yes.
Properties though are added the same way you add a method.
|
|
|
|
|
thx;)
are u from germany?
|
|
|
|
|
I had a understanding that overriding the the function with variable argument list will result in to ambiguity. However when i tried to compile and run following code on VC++ 6.0, its working as expected :
/////////////////////////////////////
void Func1( int i, ... )
//Lets refer it as Func1VariableArg
{
// do something.
}
void Func1( int i, int j)
//Lets refer it as Func1FixedArg
{
// Do something.
}
class A
{
};
int main(int argc, char* argv[])
{
Func1(1, 1); // Func1FixedArg is called as expected.
Func1(1, "1"); // Func1VariableArg is called as expected.
A a;
Func1(1, a); // Func1VariableArg is called as expected.
// This is the spoil spot
Func1(1, 1.0)// here we would expect Func1VariableArg to
//be called as second argument is double, however compiler
// implicitely typecasts it to int and calls the Func1FixedArg.
// however a warning for the same is issued at complie time.
return 0;
}
/////////////////////////////////////
Some one has any comments about this practice. Do we have any issues in this practice ?, any comments from C++ language specifications on this.
Thanks -
Suyash
|
|
|
|
|
if the compiler can find a function which signature fits exactly to the argument types it receives, then there's no problem.
the ambiguity can arrise when the compiler has to do some implicit conversions...
in you case Func1(1, 1); results in calling void Func1(int, int) because literal numbers are firstly interpreted as int s.
i don't know the priorities of the compiler's implicit casts, but take this for instance :
Func1(1, 'a');
'a' is of type char , but no function Func1(int, char) exists, so it continues looking if this call fits another existing overload before casting some parameters.
only if the compiler makes some implicit casts an ambiguity can come, because the call can then fit several overloads...
|
|
|
|
|
I want to build an application that do something like this:
- give to an ordinary user more rights over a directory or a registry key that is not intend to have normally
- when the application ends the rights are retiered
The need is to hide certain information from the user
|
|
|
|
|
I am about to start using VC++ 2005 but according to the information on MS's website it doesn't not support creation of x64 code.
I found the following page which has instructions for building x64 apps with VS 6 and VS 2003. Would this also work with VS 2005 ?
http://www.devx.com/amd/Article/21313
Is it possible to create x64 code with VC++ 2005 ?
|
|
|
|
|
Just found this page on MS's website which looks promising
http://msdn2.microsoft.com/en-us/library/h2k70f3s.aspx
Anyone tried this with VC++ 2005 ?
|
|
|
|
|
|
I don't understand Microsoft's thinking that a profiler is such a high-level tool, with it only being included in the Team edition of VS 2005. A profiler is an essential part of any development suite to tighten any speed-critical code, but it seems Microsoft would rather everyone produced bloated inefficient software. Microsoft should have included a profiler with all editions of VS, except maybe the Express versions.
Compuware's DevPartner Profiler Community Edition worked OK with VS 2002 and 2003, but it doesn't say it's compatible with VS 2005.
Anyone know of a good profiler (preferably free or cheap) which works with VS 2005 (and in particular VC++ 2005) ?
|
|
|
|
|
Hi all:
Does anybody know how to pass an array as a reference parameter? When the procedure terminates, the content in the array are modified. For example:
<br />
float* ScaleVector(float *src, float deltaT){<br />
float *ret = new float[6*p.n];<br />
float *head = ret;<br />
<br />
for (int i = 0; i < p.n; i++){<br />
float vx = *(src++);
float vy = *(src++);
float vz = *(src++);
float ax = *(src++);
float ay = *(src++);
float az = *(src++);
*(ret++) = vx * deltaT + 0.5 * ax * deltaT * deltaT;
*(ret++) = vy * deltaT + 0.5 * ay * deltaT * deltaT;
*(ret++) = vz * deltaT + 0.5 * az * deltaT * deltaT;
*(ret++) = ax * deltaT;
*(ret++) = ay * deltaT;
*(ret++) = az * deltaT;
}<br />
return head;<br />
}<br />
Because this piece of code will be looped thousand times, it keeps on allocating memories to the temporary array *ret. This leads to the memory leaking of my system. How can I find a way to make a procedure to do the job by modifying the content of the array "*src" passed in instead of returning a separate array please??
Thanks in advance!!!
Asura
|
|
|
|
|
i'd better use stl containers for this :
void Foo(const std::vector<MyType>& constRefArray) {
}
|
|
|
|
|
Hi, just use the pointer to the buffer.
Make an destination buffer float* dest[6*p.n] and give it to the function like
you did with the source buffer.
void ScaleVector(float *src, float *dst, float deltaT){
for (int i = 0; i < p.n; i++){
float vx = *(src++);
float vy = *(src++);
float vz = *(src++);
float ax = *(src++);
float ay = *(src++);
float az = *(src++);
dst[i] = vx * deltaT + 0.5 * ax * deltaT * deltaT;
dst[i*6 + 1] = vy * deltaT + 0.5 * ay * deltaT * deltaT;
dst[i*6 + 2] = vz * deltaT + 0.5 * az * deltaT * deltaT;
dst[i*6 + 3] = ax * deltaT;
dst[i*6 + 4] = ay * deltaT;
dst[i*6 + 5]= az * deltaT;
}
}
But like V2.0 said stl-vectors are a better solution.
codito ergo sum
|
|
|
|
|
In addition to the above suggestion of using vectors etc, you could also use the old methods. Note that I haven't tested it.
//Also make sure that the src parameter is now large enough.
void ScaleVector(float *src, float deltaT)
{
for (int i = 0; i < p.n; i++)
{
float vx = src[i]; // velocity on x axis
float vy = src[i+1]; // y axis
float vz = src[i+2]; // z axis
float ax = src[i+3]; // acceleration on x axis
float ay = src[i+4]; // y axis
float az = src[i+5]; // z axis
src[i] = vx * deltaT + 0.5 * ax * deltaT * deltaT; // calculate the displacement at x axis
src[i+1] = vy * deltaT + 0.5 * ay * deltaT * deltaT; // y axis
src[i+2] = vz * deltaT + 0.5 * az * deltaT * deltaT; // z axis
src[i+3] = ax * deltaT; // added speed at x
src[i+4] = ay * deltaT; // y
src[i+5] = az * deltaT; // z
}
}
this is this.
|
|
|
|
|