|
Dear geniuses,
Would you guys please teach me how to call a c program, which is a source code of C actually, from MFC/C++? Is it possible to call "mpeg2dec.dsw", which is the program that i wanna call, from the situation below??
void CMP3Dlg::OnBnClickedMpegdecoder()
{
// TODO: Add your control notification handler code here
}
Thank you
John
|
|
|
|
|
Assuming mpeg2dec.dsw has c functions that you want to call from your MFC app,
Why don't search it Calling C from C++[^]
Basically it involves avoiding C++ name-mangling by specifying the linkage specifier as C for C module. see Using extern to Specify Linkage[^]
if the mpeg2dec project has header files for those functions you are interested in your C++ program. specify the linkage as C in your C++ files.
extern "C" {
#include "mpeg2dec.h"
}
|
|
|
|
|
johndoelee wrote: Would you guys please teach me how to call a c program, which is a source code of C actually, from MFC/C++? Is it possible to call "mpeg2dec.dsw", which is the program that i wanna call, from the situation below??
The above make little sense.
What do you want to do? Do you need to call an executable? Do you need to invoke exported functions of a library?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
To start up another program (e.g., Visual Studio) via code, see here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Dear David,
I can successfully implement the program that I wanna call after adopting the method you suggested. Thank you!
Best regards,
John
|
|
|
|
|
Dear all,
Thank you for the suggestions from you guys.
Actually, I added a button on the GUI, which is the source code from Mr. Tahir Naeem from http://www.codeproject.com/KB/cpp/media_player.aspx[^]. That button is designed to call an exe from a C project for mpeg2 decodng.
For testing the program, I tried to call windows messenger by the program. The path of MSN is tested and can be called by cmd. The mpeg2dec.exe can be run at cmd as well.
However, the trials still don't work after I copied and modified the code form the suggested webpages from you guys added inside the OnBnClickedMpegdecoder(). I tried extern "C"{}, WinExec () and ShellExecute (). No window for MSN login can be displayed.
Where should I add the exe calling command? Is it inside the OnBnClickedMpegdecoder()?
I am sorry to bother your guys again as I'm a programming beginner. Grazie!
John
|
|
|
|
|
Just include required header files in c code, that is all
It is never late to learn
|
|
|
|
|
Hello everybody,
Does anyone know easy way to get any urls sourse code?
For example:
It means, it should get sourse code of www.codeproject.com (html code) without open it on
any browser.
Thanks
It is never late to learn
|
|
|
|
|
Check out URLDownloadToFile() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
i found out this is the easy way to get sourse code of any url:
void CFreeSMSDlg::OpenURL(void* param)<br />
{<br />
CInternetSession mySession;<br />
CHttpFile *pHttpFile;<br />
CString url,tmpStr;<br />
char inBuf[500];<br />
memset(inBuf,NULL,sizeof(inBuf));<br />
UINT nBytesRead;<br />
<br />
CFreeSMSDlg* pThis;<br />
pThis = (CFreeSMSDlg*)param;<br />
bool bNotFinished = true;<br />
<br />
do<br />
{<br />
try<br />
{<br />
pHttpFile =(CHttpFile *) mySession.OpenURL(pThis->pUrl);<br />
}<br />
catch (CInternetException)<br />
{<br />
::MessageBox(NULL,_T("Received Exception from OpenURL()"),_T("Error!"),NULL);<br />
bNotFinished = false;<br />
}<br />
if(pHttpFile == NULL)<br />
{<br />
::MessageBox(NULL,_T("Error in OpenURL"),_T("Error!"),NULL);<br />
bNotFinished = false;<br />
}<br />
else<br />
{<br />
nBytesRead = pHttpFile->Read(inBuf, sizeof(inBuf));<br />
<br />
}<br />
<br />
} <br />
while (bNotFinished);<br />
<br />
pThis->bIsSent = true;<br />
_endthread();<br />
<br />
}<br />
It is never late to learn
|
|
|
|
|
Hi Friends,
i have a peculiar problem. I have written a Dll for Keyboard and Mouse hook. And have exported two function which has the code to install and uninstall hooks. when I call the install and un install function for the first time, they work perfectly alright. but from the second time, they are not working. That is the hook is not set. I dont understand why?. can anybody help me?
thanks in advance
P.Somasundaram
|
|
|
|
|
somasundarambe wrote: I dont understand why?.
Have you bothered to use the debugger? It might help in lessening your lack of understanding.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all,
Can anybody tell me is there any other api for finding resource handle except AfxGetResourceHandle() in vc2005
thanks in advance...
|
|
|
|
|
|
Hello there,
I believe that AfxGetResourceHandle() is simply returning the allocation base of the module which contains the resource your attempting to access. This is so it can correctly calculate PE image offsets. Therefore you should be able to simply do the following:
If the resource is located inside the module your executing code from you can do this:
#define MyGetResourceHandle ((HINSTANCE)&__ImageBase)
HICON hIco1 = (HICON) LoadImage(MyGetResourceHandle,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,16,16,0);
Best Wishes,
-David Delaune
|
|
|
|
|
I've a class which has a member of Gdiplus::Bitmap * ,
any way to serialize a Gdiplus::Bitmap object?
Thanks.
|
|
|
|
|
What about save the Bitmap to stream (Image::Save)[^], where the stream resides in memory (CreateStreamOnHGlobal)[^] and then writting the stream to file CArchive::Write. Reverse the process for loading object CArchive::Read, CreateStreamOnHGlobal, Bitmap::FromStream. overload << >> on CArchive for insertion and extraction.
|
|
|
|
|
|
Hi everyone,
i am doing concatination in my activeX control project.means i am having two varibles one is MemId is of type LPCTSTR and another one is strmsg is of type char *strmsg.this is in read block function.
i am doing like this:
MemId=dStr;
strmsg=strcat(strmsg,MemId);
MessageBox(strmsg);
it is not giving error but when i execute my actual program in that i used this activeX control. that time is giving send error or dont send error message box.
afterwords i changed this to for first time i used string copy function but it is also giving same error.
Please Help Me what's wrong with my code.
**********THANKS IN ADVANCE*********
Savitri
|
|
|
|
|
Have you allocated strmsg?
possibly you are not allocating char *strmsg; you need to allocate memory for the string. something like char strmsg[YOUR_STRING_SIZE]; char *strmsg = new char[YOUR_STRING_SIZE];
savitri wrote: strmsg=strcat(strmsg,MemId);
It seems your module is not unicode as strcat doesnot give error at compilation taking (char *, LPCTSTR).
And as a side note, IMHO, when you are using generic string data type LPCTSTR always use generic text manipulation API's and data structure, use _tcscat inplace of strcat.
Unicode, MBCS and Generic text mappings[^]
generic text apis start with _tcsxxx search in msdn index when you want a mapping to string functions with strxxx
modified on Tuesday, March 25, 2008 6:46 AM
|
|
|
|
|
It's spelled "CONCATENATION"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Hi
I m working in vs 2005 using Win Mob 5.0 Smart Phone SDK using Win32 APIs. When i m trying to add icons in a ImageList by using ImageList_AddIcon macro it gives error 'ImageList_AddIcon': identifier not found. While all other macros are working fine. Also i have tryed with ImageList_ReplaceIcon but same error.
Thanks in Advance
|
|
|
|
|
|
Thanks for your suggestion but still not working.
|
|
|
|
|
Try DRA::ImageList_AddIcon
|
|
|
|