|
Hello,
I tried to put a programme into the main one as a function, but it didn´t work. Is there a way to "call" another program from the main one? Please don´t use much technical language, as I´m only beginning. All help would be much appreciated.
|
|
|
|
|
I suggest you look here[^].
|
|
|
|
|
I think you want to launch another program in your application.
::ShellExecute(NULL,_T("open"),_T("notepad.exe"),NULL,NULL,SW_SHOWNORMAL);
It will launch notepad.exe.
Regards
|
|
|
|
|
Hi Pranit,
Thanks for the info. Do I need a special header for ::ShellExecute, type include<xxxxx> for devc++?
|
|
|
|
|
Follow the link provided by Luc. Since you are only beginning, this will serve you well. The documentation he points to contains everything you need to know about including it, the "prerequesite calls" and the header file that must be included. MSDN documentation follows that standard for all the calls so you can determine that for anything. No need to ask and sit and wait for someone to answer, it's all in your hands.
|
|
|
|
|
|
Hi Pranit,
Thanks a lot. I thence dowloaded the latest version and installed it.
|
|
|
|
|
The first two replies suggest "ShellExecute". However, that's "launch", not "call" as a function. If you want a "return value" or other "results" of the program[me] then you will need a more technical discussion on what you want.
CreateProcess()[^]
allows you to monitor the completion, get the completion status (which could mean anything to your application, like a result) or do other ways of getting more complex results.
Good luck.
|
|
|
|
|
Hi Chuck,
Your reply seems just what I need. Sorry about the lack of information, it´s just lack of experience on my part. What I´m trying to do is to read an entering car´s number plate, which is done by ANPR camera and software (bought) which includes OCR,get the number plate from this program, then compare it with about 400 registered cars. If a match is found, another program sets one of the pins of the parallel port, so I´ve got to execute my 3 programs sequentially to achieve the desired result. The main program fills in a database with number plate, address and owner name, with editing facility. My second program gets the entering number plate and checks it against the forementioned list, and the third program lets the car in by opening the gate if the compare is true. Well, that´s about it. Of course, I´m struggling along trying to keep afloat, and the replies I´ve had have all pointed in the right direction, I think. If you have any suggestions at all which could help, I´ll gratefully accept.
Thanks again..
|
|
|
|
|
Hello all.
In all the time I have worked with C++ / MFC I have usually created data-centric applications, so I'm full with apps using ATL OleDB and the ODBC classes (CRecordset et. al.). So, I usually simply bypass the CDocument, or store small ammounts of info there (like the current user's ID and encrypted connection strings).
This time, however, I've been instructed to build a full doc-view application, with all the bells and whistles. It's kinda a internal product, so it will be a desktop app with no connectivity, and the files the app generates must be shared to other users. So, a doc-view app.
I've been wondering, however, how to create the data model. I mean, I created a base class that inherits from CObject, implements serialization and has a GUID as a property and such. Then my model classes inherit from this one. Some of this classes have collections of another one as their child, and so on. Say:
class CEntity : public CObject
{
CGuid GetId() const; };
class CContact : public CEntity
{
};
class CMeeting : public CEntity
{
CArray<CContact*> m_objParticipants;
};
Here the thing is that a CContact object can be used elsewhere, so it is not owned by the CMeeting. So, I'm guessing that the CContact collection should be created in the CDocument-derived class, and so the CMeeting one should have only references to a) the CDocument and b) the contact's CGuid, so that it can search for the actual pointer when needed. This would mean that CDocument should have to serialize the object rather than CMeeting, and I'm thinking CMeeting should only serialize the CGuid value... or something similar.
Yet... it doesn't feel quite right, and I'm rather confused as to which approach to use. So, I was wondering if you CPians could help me with advises, experiencies and how you solved similar problems. Any comment will be really appreciated.
Cheers and thanks in advance.
|
|
|
|
|
I know how to make IE not prompt this error.
How can I compile and distribute a program that wont
trigger this warning? Please let me know.
|
|
|
|
|
|
Hi all,
i get the details of any file using IShellFolder2::GetDetailsOf method,its working fine for other files.
but fails in case of MS Office files of 2007 and upper version of MS Office.
please help me to get these details of these files.
thanks in advance.
|
|
|
|
|
Hello,
I´m trying to output a byte to parallel printer port using dev-c++. I´ve included dos.h and conio.h, and I´ve put inpout32.dll in the system32 dll folder, but when I try to compile, the compiler stops at the "using system" instruction. I`m not very experienced with C programming and am feeling my way around, as yet.What I´m trying to do is to send a signal which can be read by a PLC which will in turn open an automatic barrier to let a registered vehicle in.
Can anybody help me out?
Many anticipated thanks
Andrew
|
|
|
|
|
After the #include <...> lines, insert the following:
short _stdcall Inp32(short PortAddress); */
void _stdcall Out32(short PortAddress, short data);
and link with inpout32.dll
Sample code:
#include <conio.h>
#include <windows.h>
#include<iostream>
short _stdcall Inp32(short PortAddress); */
void _stdcall Out32(short PortAddress, short data);
using namespace std;
int main()
{
cout<<"Parallel Port Interfacing"<<endl;
cout<<"Press 8 to forw, 2 to reverse,4 to left,6 to right,1 to forw&left and 3 to forw&right:"<<endl;
int inp;
do
{
inp=getch();
out32(0x378,0x00);
if(inp=='8')
{
cout<<"forward";
out32(0x378,0x01);
}
else if(inp=='2')
{
cout<<"reverse";
out32(0x378,0x02);
}
else if(inp=='4')
{
cout<<"left";
out32(0x378,0x04);
}
else if(inp=='6')
{
cout<<"right";
out32(0x378,0x08);
}
else if(inp=='1')
{
cout<<"forward and left";
out32(0x378,0x05);
}
else if(inp=='3')
{
cout<<"forward and right";
out32(0x378,0x09);
}
}
while(inp=='1'||inp=='2'||inp=='3'||inp=='4'||inp= ='6'||inp=='8');
system("pause");
return 0;
}
|
|
|
|
|
Thanks for kindly answering. Using your sugestion solved the problem. Thanks again,
Kindest regards
|
|
|
|
|
RealHigh wrote: but when I try to compile, the compiler stops at the "using system" instruction.
Care to share the exact error message as well as the offending statement?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hi David,
Thanks a lot. Yes I threw out the code I was trying compile, and just started anew, using suggestion from just-in-time. I still don´t know if the code actually works, but at least it´s compiled ok.
Kindest regards
|
|
|
|
|
Hi,
I am using "DrawText(HDC hDC,LPCTSTR lpchText,int nCount,LPRECT lpRect,UINT uFormat)" in my project, it returns 0 means function fils. In which case this function will fail and whether there is error code for this function?
I have gone through MSDN but they didn't mentioned the reason for failing.
Thanks in Advance,
Ratheesh
|
|
|
|
|
Have you tried GetLastError() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
That usually works for most WinAPI calls that don't return an actual error message off the back... but its usually specified in the MSDN documentation... for whatever reason, they didn't specify this for this call[^]. That omission is a bit strange.
|
|
|
|
|
The problem isn't with the DrawText call itself. Apparently something is NULL in
DrawText(HDC hDC,LPCTSTR lpchText,int nCount,LPRECT lpRect,UINT uFormat)
An access violation occurs in unmanaged or unsafe code when it attempts to read or write to memory that has not been allocated, or to which it does not have access. Not all reads or writes through bad pointers lead to access violations, so an access violation usually indicates that several reads or writes have occurred through bad pointers, and that memory might be corrupted.
[This] might shed some light.
|
|
|
|
|
TopCoder23 wrote: An access violation occurs
Where exactly did they say they experienced an access violation? They could have simply passed in an invalid parameter option for format or the function could have simply checked for a NULL parameter and returned indicating failure based on that branch statement.
|
|
|
|
|
Try showing the actual code from your program, and make sure that all the parameters are valid.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
i search for an function to restore folder content to previous status/version?
I mean, if i add new files to folder, i need in some cases to restore a status before adding new files!?
Restore to previous version?
Is there an API to use for that or some sample code??
Simple single deletion of any each file is not the way, because there can be many files added(hundreds)!
Thanks for any help!
|
|
|
|
|