|
Hey every one...
I am asking about how to creat exe files from my application...
I want to make a program that creat other .exe files with a specific values.
for example, When I am running my application, I enter a value (let's say my name) and click on a button named "creat", then an valid exe file will be created and the value (my name) will be inside it.
thanks : )
|
|
|
|
|
what you're asking is very simple but I am curious what would you like the exe to do.
and then I will give you a solution
gabby
|
|
|
|
|
I liked your answer.
To many of the quesions (small amount) seem to be aimed in the wrong direction.
This is a new one and I would also like to know what he would what it to do.
INTP
|
|
|
|
|
:-DHey
what's happening here.
????????
|
|
|
|
|
I don't know why you thing I will use it in the wrong way?
( I don't know how it can be used in a wrong way?)
and I want the exe file to include some buttons and edit box, or maybe include some codes to solve a math. question or any thing else.
why I want exe file?
because it is an extension file, and I already study how to make the other files, like .txt or .html, but never learnt how to make .exe files
so I will be thankful for any help, and Believe me I am not going to use it in wrong way.
|
|
|
|
|
I think you are looking for Dialog based application.
here is Some step that will help-:
!-Open MS Visual Studio 6.0
!-Click on FILE|NEW,and wait for property page to open.
!-select PROJECTS|MFC AppWizard(exe),Do remember to give the name of project.CLick Next
!-Select type to Dialog based,and click next till wizrad over.
!-now you are presented with Dialog Box editor,drag and drop your Control to Dialog box,build and execute the Preoject to see your exe
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Yeah I know, but I want my project which is an exe file to creat other exe files.
thanks alot
|
|
|
|
|
you must first have the contetnt of the exe file somewhere. in the resources or just in an ordinary file.
then you open the new file where you want it to be created:
FILE *exec;
exec=fopen();
while(true)
{
data=readfile(oldfile);
fprintf(exec,data);
}
this is the idea of the code.
To load it from the resources is a little longer code and I am tired so I won't write the code. try to read the MSDN more.
good luck.
|
|
|
|
|
thank you. I think he ust said what the exe should do but it seems kind of hard to do.
gabby
|
|
|
|
|
Thank you very much for your help.. I got also the idea of how to do it, but I still can't do it.... can you give which title i should search in MSDN
I know it is hard, but I will not give up
thanks again
|
|
|
|
|
Hmmm hard to tell.... The MSDN is really big.
What sort of problem are you having now. If it is about manipulating files read about I/O functions which you can find by going to the index tag in the MSDN and type any of the functions (ex CopyFile) and in the bottom of the page you get a link like this:
See Also
File I/O Overview, File I/O Functions, CopyFileEx, CreateFile, MoveFile ;
You may choose any of those but it advisable that you should choose "File I\O overview".
Then if you have problems with manipulating strings go to the index tag as well in the MSDN and write a str function ( ex: strcmp) then you will see that the function has also an example along with the explanation. In the bottom of the page you get this link: "String Manipulation Routines". Push it and you will see al the possible functions all with an exapmle each.
I thing that these were the issues you where concerned in, otherwise tell what exactly can't you do.
Good Luck.
gabby
|
|
|
|
|
Thanks alot man... your replay includes many things, so I need to be over them all, and try it one by one... so it will take some time until I ask the next question
I am very thankful for your help
thanks again
|
|
|
|
|
no problem I am here to help whenever is neccesary.
gabby
|
|
|
|
|
Hi,
I'm a C++ newbie and have a liitle problem I hope someone can help me with here.
I have a Visual C++ project consisting of about 20 source files, one of which contains main(). I originally built a dialog-based application, and have no menus in the application. I am trying to run main(), by clicking on a Control button, "Analyze", inside the OnAnalyze() function.
From my understanding, main() is supposed to harness all my other source files and implement it. Now, I need to run main() from a control button, in my MFC application. The project compiles with no errors at present but I don't know how to run main() with the control button.
Or would it may be necessary to implement an instance of the control in main()? Otherwise, since I'm running Visual C++, do I need to make any changes to WinMain()? or do I make a call to WinMain() from my control? how would i do this?
Thaanks a lot in advance!
|
|
|
|
|
I tried
void CKuchukDlg::OnAnalyze()
{
// TODO: Add your control notification handler code here
extern main();
return main();
}
but because OnAnalyze() already has type "void", it cannot return a value; so I get error C2562.
Thanks.
|
|
|
|
|
How did you manage to get to 20 source files without knowing how to program?
(Never mind) The main() it the enterance to your program. That is you have to have one and only one main() function (routine, method or what ever you what to call it), otherwize you have no program.
Now down to business!
What ever code you put in the main() function move it to another function (name it anything you like). Now all you have to do is call that new function (simple).
Oh! By the way the new fuction should not be in the same file as the origanal main() funtion and the file containing the origanal main() funtion should not be included in the build.
INTP
|
|
|
|
|
John,
Thanks a lot for the constructive criticism. Yeah, i'm definitely a newbie grappling with the fundamentals. I moved the code from main() to my control button, including the appropriate #include files, and the project currently comiples without error.[THANK YOU!] I also deleted the source file containing main()(didn't bother to have any main, since WinMain() is supposed to be hidden anyway....However, while it compiles without error, it doesn't seem to do what I want it to!!
Below is the code:
void CKuchukDlg::OnAnalyze()
{
// let maximum number of layers = 100: this value can be modified.
int num_layers;
CKuchukDlg MyClass; // instance of object MyClass of class CKuchukDlg
MyClass.m_iLayers = num_layers;
int i = 1; // index to count what line is being read: start at line 1;
int H_ft[100],kh_md[100], kv_md[100];
float visc_cp[100], por[100], ct_psi[100];
char line[100];
ifstream inputdeck;
inputdeck.open("input.txt", ios::in);
if (inputdeck.fail())
{
//cout<<"Error With Files!";
AfxMessageBox("File Read Error!", MB_ICONSTOP);
}
else
{
cin.ignore(60, '\n');
cin.ignore(60, '\n');
while (i <= num_layers && cin.getline(line,100)) //
{
cin>>H_ft[i]>>kh_md[i]>>kv_md[i]>>visc_cp[i]>>por[i]>>ct_psi[i];
i++;
} /* while block */
}
ofstream outputdeck;
outputdeck.open("output.txt", ios::out);
outputdeck<<"Pressure\n";
extern double pressure(double x);
extern double press;
outputdeck<<press<<endl;
}
On clicking the "Analyze" button, the whole application closes. This is not supposed to happen.
I'd be greatful for any further input you or anyone else may have.
Thanks a lot!
|
|
|
|
|
void CKuchukDlg::OnAnalyze()
{
int num_layers;
CKuchukDlg MyClass;
MyClass.m_iLayers = num_layers;
int i = 1;
int H_ft[100],kh_md[100], kv_md[100];
float visc_cp[100], por[100], ct_psi[100];
char line[100];
ifstream inputdeck;
inputdeck.open("input.txt", ios::in);
if (inputdeck.fail())
{
AfxMessageBox("File Read Error!", MB_ICONSTOP);
}
else
{
cin.ignore(60, '\n');
cin.ignore(60, '\n');
while (i <= num_layers && cin.getline(line,100))
{
cin>>H_ft[i]>>kh_md[i]>>kv_md[i]>>visc_cp[i]>>por[i]>>ct_psi[i];
i++;
}
}
ofstream outputdeck;
outputdeck.open("output.txt", ios::out);
outputdeck<<"Pressure\n";
extern double pressure(double x);
extern double press;
outputdeck<<press<<endl;
}
In general this code makes no since!
1) You are using unitialize variable, which should cause the compilire generate errors (or crash the program).
2) You open of file for reading and read nothing from it.
3) You declare a global external funciton and then do not call it.
I hate to say this but, you need to do a lot more studying (or find a local tutor) before writing any more code like this.
INTP
|
|
|
|
|
Immediately after my last post, I removed the instance of CKuchukDlg, MyClass; the application stopped closing, but appeared to do nothing. I later checked the folder, and found that "output.txt", had been written, with a header, Pressure, as expected and only one pressure data, "0".
On implementing your corrections[THANKS! Yep, def. a newbie--> new, no formal training, confusing usage of cin and inputdeck for reading files, etc, etc; but very much willing to learn nevertheless...], I implemented the following, with the same result:
void CKuchukDlg::OnAnalyze()
{
// let maximum number of layers = 100: this value can be modified.
int num_layers = 100;//may be discarded later; no apparent need, now
int i = 0; // index to count what line is being read;
extern int K;
int H_ft[100],kh_md[100], kv_md[100];
float visc_cp[100], por[100], ct_psi[100];
char line[100];
ifstream inputdeck;
inputdeck.open("input.txt", ios::in);
if (inputdeck.fail())
{
//cout<<"Error With Files!";
AfxMessageBox("File Read Error!", MB_ICONSTOP);
}
else
{
inputdeck.ignore(60, '\n');
inputdeck.ignore(60, '\n');
while (i <= K && inputdeck.getline(line,100)) //
{
inputdeck>>H_ft[i]>>kh_md[i]>>kv_md[i]>>visc_cp[i]>>por[i]>>ct_psi[i];
i++;
} /* while block */
}
ofstream outputdeck;
outputdeck.open("output.txt", ios:out);
/*code to test that inputdeck.ignore actually works:
outputdeck<<inputdeck.rdbuf();
--> it does! the 1st 2 lines are skipped;
the 1st 2 lines contain explanatory header text, not useful in the computation; the rest of input.txt is a table of data*/
outputdeck<<"Pressure\n";
extern double pressure(double x);
extern double press;
double pressure(double x);
outputdeck<<press;
AfxMessageBox("Output file Generated!", MB_ICONINFORMATION|MB_OK);
}
Would I be correct in assuming my problem would be (1) or (2) below?
1) My code to generate Pressure Data, called "press" is incorrect somewhere;
2) the statement -> outputdeck<<press; is incorrect, or this code in OnAnalyze() is still incorrect somewhere?
i actually expect to see a stream of pressure data, based on my earlier statements.
I'd appreciate your continued response as well as anyone else's.
Thanks a lot!
P.S: SAMPLE OF INPUT.TXT TABLE DATA; FORMATTING MAY BE BAD, BUT ITS A TABLE OF DATA....YOU CAN SEE WHY I'D WANT TO REMOVE THE 1ST 2 LINES.
--------------------------------------------------------------------------
TABLE OF RESERVOIR PARAMETERS
H(ft) kh(md) kv(md) visc(cp) por ct(/psi)
40 160 20 1 0.2 0.00005
20 100 16 1 0.2 0.00005
10 60 12 1 0.2 0.00005
100 100 10 1 0.2 0.00005
30 40 4 1 0.2 0.00005
10 20 2 1 0.2 0.00005
|
|
|
|
|
Remeber a computer is a stupid machine, it does exactly what you tell it and nothing more. Well ok, since we are using libraries written by other peaple, there is a certain level of trust required.
I am still suprised your code compiles at all, let alone runs without crashing.
1) You have introduced a new magic number (extern int K;), do to how you are using it the value of K must be in the range 0-99. (MAGIC NUMBERS ARE BAD AND DANGERIOUS)
2) You have added a new prototype repressenting the same function, but still do not call it. (It does not look like it would do anything any way).
extern double pressure(double x);
double pressure(double x);
--------------------------------------------------------------------------
Here is what you are telling the computer to do:
1) You open the file and read data in (while praying that K < 100). Then you proceed to ignore the data you just read from the file.
2) You open a file for output. Then you write one word to it "Pressure\n" follow by anouther magic number press. If you read this new file into a string buffer the string would consist of the following: "Pressure\n?" (where '?' is magic number).
3) Show a message box saying the file was generated.
--------------------------------------------------------------------------
Lets analyze the problem:
1) The file consist of two lines of informaional text followed by zero or more lines of numerical data. This implies we may need a variable size array to store the numerical data, unless an maximum size is specifed.
Note: To keep it simple we'll assume maximum array size of 100.
2) The numerical (text) data per line consist of 3 interger values and 3 floating point values no more no less. This implies a record of numerical data stored in a text format, which needs to be translated into a binary format.
struct tagMyDataRecord { int H_ft, kh_md, kv_md; float visc_cp, por, ct_psi; };
tagMyDataRecord recArray[100];
inputdeck>>recArray[i].H_ft>>recArray[i].kh_md>>recArray[i].kv_md>>recArray[i].visc_cp>>recArray[i].por>>recArray[i].ct_psi;
3) Once the data has been loaded we to analyze it and output the results to a file. Now since the given code does not analyze the data nor calls any function to do it, I'll assume that all the data is required to produce a single floating point value.
--------------------------------------------------------------------------
Here is rewrite of your code that should work, provided that complete the pressure() function:
struct tagMyDataRecord { int H_ft, kh_md, kv_md; float visc_cp, por, ct_psi; };
double pressure(tagMyDataRecord* precArray, int nSize)
{
double RetValue = 0.0;
for( int i=0; i<nSize; ++i )
{ }
return RetValue;
}
void CKuchukDlg::OnAnalyze()
{
ifstream inputdeck;
inputdeck.open("input.txt", ios::in);
if (inputdeck.fail())
{
AfxMessageBox("Error: Could not open data file!", MB_ICONSTOP);
return;
}
inputdeck.ignore(60, '\n');
inputdeck.ignore(60, '\n');
int recCount = 0;
tagMyDataRecord recArray[100];
while( recCount < 100 && !(inputdeck.fail() || inputdeck.eof()) )
{
inputdeck>>recArray[i].H_ft>>recArray[i].kh_md>>recArray[i].kv_md;
inputdeck>>recArray[i].visc_cp>>recArray[i].por>>recArray[i].ct_psi;
++recCount;
}
if (inputdeck.fail())
{
AfxMessageBox("Error: Data file read!", MB_ICONSTOP);
return;
}
double result = pressure(recArray, recCount);
if (!result)
{
AfxMessageBox("Warning: Pressure = 0.0, this may be an error!", MB_ICONSTOP);
}
ofstream outputdeck;
outputdeck.open("output.txt", ios:out);
if (ofstream.fail())
{
AfxMessageBox("Error: Could not open output file!", MB_ICONSTOP);
return;
}
outputdeck<<"Pressure"<<press<<endl;
AfxMessageBox("Output file Generated!", MB_ICONINFORMATION|MB_OK);
}
INTP
|
|
|
|
|
I created a new class that derived from CEdit. Here is OnChar function:
<br />
void CMyEdit::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags)<br />
{<br />
if( nChar>='a' && nChar<='z')<br />
{<br />
nChar -= 'a'-'A';<br />
}<br />
CEdit::OnChar(nChar, nRepCnt, nFlags);<br />
}<br />
I just wanted to capitalize all typed chars in the edit box. But It seem not to work.
Where is the problem? Please, help.
Thanks for reading.
|
|
|
|
|
try using PreTranslateMessage()
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Thank you. But does anyone explain more why changing nChar in OnChar function did not effect?
|
|
|
|
|
nguyenvhn wrote:
nChar -= 'a'-'A';
First off you might look at an ascii table before you do some thing this strange. Second I am not even going to calculate what value this will result in.
If you where going to convert ascii characters in this manner you would have to do the following:
if( 'a' <= nChar && nChar <= 'z' )
nChar = 'A' + (nChar - 'a');
To do it properly you would do the following:
nChar = toupper(nChar);
Ok! I lied I (calculated) tried your equation and it worked (mathmaticaly), but don't do it.
INTP
|
|
|
|
|
Perhaps you could just set the ES_UPPERCASE style? To change the style after the control has been created, use SetWindowLong() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|