|
In a DLL function,I need to call a exe and pass parameters to that exe.
Actually the parameters are to be used in a function of the exe file.
In Dll function
<br />
extern "C" __declspec(dllexport) PlotWave(double *Data,int nData,int mode)<br />
{<br />
HWND hExeWnd=FindWindow(NULL,"WFP"); <br />
if(hExeWnd)<br />
{ <br />
SetForegroundWindow(hExeWnd);<br />
ShowWindow(hExeWnd,SW_SHOW);<br />
} <br />
else<br />
ShellExecute(NULL,"open","C:\\wfp.exe",NULL,NULL,SW_SHOW);<br />
<br />
}<br />
Now I have to pass those parameters(double*,int,int) to the wfp.exe.
I know in ShellExecute we can pass parameter to the file we want to open.
But how can my wfp.exe accept that parameters.
What should I write in my wfp.exe to do so.
I tried using SendMessage(hExeWnd,WM_PLOTWAVE,0,0).
My wfp.exe only can recieve the message but how to get the parameters
because SendMessages() accepts only WPARAM and LPARAM.
Help please!
|
|
|
|
|
poda123 wrote: But how can my wfp.exe accept that parameters.
What should I write in my wfp.exe to do so.
Look up GetCommandLine and CommandLineToArgv .
|
|
|
|
|
poda123 wrote: What should I write in my wfp.exe to do so
Entry point function of your exe(main,winmain etc.) will take care of that.
You need to Parse its parameters. In case of windows application you can use GetCommandLine , as suggested earlier.
poda123 wrote: I tried using SendMessage(hExeWnd,WM_PLOTWAVE,0,0).
My wfp.exe only can recieve the message but how to get the parameters
because SendMessages() accepts only WPARAM and LPARAM.
Help please!
In this case, you can wrap required information in structure. i.e.
class myInfo
{
double *m_pDouble;
int m_iFirst;
int m_iSecond;
public:
myInfo():m_pDouble(NULL),m_iFirst(0),m_iSecond(0)
{
}
};
myInfo *pSendInfo = new myInfo;
SendMessage(hExeWnd,WM_PLOTWAVE,(WPARAM)pSendInfo,0);
Now, in command handler you can unwrap the information.
|
|
|
|
|
Thanks for your replies.
As I need to pass a double pointer as a parameter,
ShellExecute would not be working.
As suggested by prasad,I used SendMessage() function.
In the DLL function
<br />
extern "C" __declspec(dllexport) void __stdcall PlotWaveForm(double *Data,int <br />
nData,int Mode)<br />
{<br />
double *pData=new double;
SendMessage(hExeWnd,WM_PLOTWAVE,(WPARAM)pData,0);<br />
delete pData;<br />
}<br />
In the recieving application(.exe),I cast the pData to double* as
<br />
void CWFPDlg::PlotWave(UINT Msg,WPARAM wparam,LPARAM lparam)<br />
{<br />
double *WaveData=NULL;<br />
WaveData=(double*)wparam;<br />
}<br />
Since wparam is a pointer to double array,
I used WaveData[i] to get values to plot the wave,but the values
in the array are not correct.What's the problem.
|
|
|
|
|
There should not be any problem.
poda123 wrote: double *pData=new double;//just checked for one parameter
SendMessage(hExeWnd,WM_PLOTWAVE,(WPARAM)pData,0);
delete pData;
I hope you have passed some value in array.
poda123 wrote: double *WaveData=NULL;
WaveData=(double*)wparam;
Does WaveData showing some garbage or showing just NULL.
If its showing garbage value; try commenting delete pData; statement after SendMessage .
|
|
|
|
|
You can also use WM_COPY message during execution or use shared memory
|
|
|
|
|
Plz provide me some link related to mfc collection classes especially map classes
|
|
|
|
|
|
thnax alot for the link.
are there any good articles in code project for easy understanding?
|
|
|
|
|
A google search on "mfc collection classes" yields links to many articles.
The MFC/ATL documentation for each class is pretty good too, with code samples.
|
|
|
|
|
Raj Gopal wrote: Plz provide me some link related to mfc collection classes especially map classes
Here is one[^].
BTW a simple search with Google with keyword as "MFC Collection classes" should have helped you much better.
|
|
|
|
|
thx for the link sir.
are there any good articles in code project for easy understanding?
|
|
|
|
|
Hi All,
I use a CStatic to show a bitmap in a dialog. The bitmap is a thumbnail of a file. Everytime when a file is chosen, the code call CStattic::SetBitmap to associates a new bitmap with the static control and the bitmap will be shown out immediately. But I minimize the dialog and maximize the dialog again, the bitmap in the CStatic control can't be shown out.
Do you know how to show the picture out again when the dialog is maximized?
thanks,
Eric
|
|
|
|
|
Sounds like you've got a problem with the control not repainting itself. What if you call Invalidate() on the CStatic when your form is shown ? ( NOte : this should have happened by itself )
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Is the bitmap getting deleted after you set it?
If you're using CBitmap, and it goes out of scope, it will delete the gdi object.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
The code is like this:
{
CBitmap tempBitmap;
...
HBITMAP hBitmap = HBITMAP(tempBitmap);
m_picHolder.SetBitmap(hBitmap);
...
}
When call SetBitmap again, the bitmap can be shown out. But it will disappear after minimize and maximize the dialog.
Thanks,
Eric
|
|
|
|
|
Eric Vonjacson wrote: CBitmap tempBitmap;
You need to create on heap , using new.
Or , make CBitmap object, as member variable along with m_picHolder.
|
|
|
|
|
I think tempBitmap is deleted when it goes out of scope, which also deletes the gdi resource it's wrapping.
Try adding a CBitmap member variable to your class like:
CBitmap m_bitmap;
then in your function:
{
m_bitmap.LoadBitmap(); // or however you're getting it
m_picHolder.SetBitmap(m_bitmap);
}
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Now, I am want to use bitwise operation, ex: add 1 or 0 to position in 8_bit. But I don't know about this.
Can you help me?
Thank's lot.
Best regard!
lang tu
|
|
|
|
|
What do you want to do, exaclty ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I need a program that operate with bit.
Example:
unsigned long x;
I want to put 1 or 0 to the 6th bit in x.
Can you help me?
lang tu
|
|
|
|
|
Well, the numbers you want for each bit are:
1
2
4
8
16
32
64
128
256
512
etc.
So, x |= 128 will set the 8th bit. x &= ~128 will strip that bit.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If you are saying the the eighth bit is the 27 bit you want to be set:
<br />
unsigned int v = 1;<br />
<br />
v |= 1 << 7;
<br />
v |= 1 << 6;
<br />
v ^= 1 << 6;
<br />
v ^= 1 << 0;
<br />
v ^= 1 << 0;
-- modified at 22:46 Wednesday 29th November, 2006
|
|
|
|
|
Set (1) high order bit of a byte:
unsigned char ByTe = 0;
byte |= 0x80;
Reset (0) high order bit of a byte:
unsigned char ByTe = 0x80;
byte &= ~0x80;
|
|
|
|
|
Do vectors or CObArrays (and other similar containers/classes) automatically free their memory when the object containing them is destroyed? In other words, I have a vector as a data member in my class. When my class is destroyed, does the vector free whatever memory it held, or do I have to explicitly do that in my classes destructor?
Thank you,
BP
|
|
|
|