|
Hi,
How to write some data from listcontrol to ".html" file using MFC.
Please answer this question.
|
|
|
|
|
|
Hi
Sorry for the confusing title, but i didn't have a clue how to summarize my question.
This is the situation:
I'm making a program which creates an exe (in memory), writing this exe to disk, and executing it from within the program (on another thread). The user then uses that program which was written to disk, and when he exists it he returns to the main program, and the exe gets deleted.
This is the problem:
I need to somehow protect the written exe from being read by another app. As i implemented it atm, you can just alt-tab out of the program (which was written to the disk, and executed from the main program) and copy the generated exe somewhere else. When alt-tabbing back to the program, and exiting it, the user has this exe which shouldn't be possible.
Solution?
Is there a way to protect the written exe so the user can't copy it to another location (or read it with some hex editor), but the OS can execute that same exe? I've tried different stuff already, but all without succes. The best would be i could execute the program from in-memory, but i don't think thats possible, right?
Thx in advance for any help.
|
|
|
|
|
Donny Tytgat wrote:
I'm making a program which creates an exe (in memory), writing this exe to disk...
Be sure to use a non-descriptive filename (e.g., GetTempFileName() ) instead of something obvious like mysupersecretprog.exe.
Donny Tytgat wrote:
The best would be i could execute the program from in-memory, but i don't think thats possible, right?
Yes, it's possible. There are a few examples available via Google. In summary, it involves knowledge of the PE file format.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
The name of the exe isn't really important, the user can just use a taskmanager to retrieve what file is being executed (and its always in the same dir).
I searched a bit for the PE file format, and executing a file from memory but it all seems a bit "overkill" (work-wise) for what i'm trying to do (which is basically something to prevent cheating in a game). Dont wanna spend ages on something which can be cracked using some memory monitoring tool, just wanted to make it a bit harder on potential cheaters.
Anyways, thx for your answer David Crow. At least i know what the PE file format is now .
|
|
|
|
|
Hello
I want to develop a software in vc++ which takes character size more than 2 bytes.
It means I cannot use UNICODE .
What settings should I use in Visual Studio or how can I use character size more than 2 bytes ?
|
|
|
|
|
Is there any special case where u need more than 2 bytes to store character?
|
|
|
|
|
What language are you trying to store?
Unicode handles every language available on the planet (including Klingon, Vulcan and Welsh) with a lot of room left for new languages. So unless you have invented some new language, UNICODE will work.
What are you actually trying to do?
Neil
|
|
|
|
|
ok thanks
I thought that there might be a case where I have to handle more than 2 bytes size and the software should not fail.
anyways Is this possible or impossible ?
|
|
|
|
|
Answer is simply no. you cant do it in VC++ atleast, but you can always design your application to store more than 2 byte per char, but none of the windows api will be of any use coz they accept either ascii or unicode character set.
-prakash
|
|
|
|
|
The 32 bit versions of unicode handle everything. The 16 bit versions miss a lo. (mostly Asain languages where there are a different symbol for each word) Windows is mostly 16 bit unicode.
UCS-8 (which is common on unix) is variable size, IIRC it can use up to 6 bytes, or as little as 1.
|
|
|
|
|
are there any special reasons for that you could explain fully here ?
UNICODE provides 2 bytes per character, that allow you to have 65535 different characters in the same "set", which is large enough to represent all the characters of the world...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
hmmm - does it support those elven-characters from Lord of the Rings ?
|
|
|
|
|
Yes you can use unicode. However you cannot use the uncode functions built into windows, because they use UCS-2 which is only 16 bit.
I would typedef unsigned long to something like my_unicode_type, so that if you come up with something better latter you only need to change your type in one place. This depends though, if you are writting a class to wrap everything it might not be required.
|
|
|
|
|
I use Teradata database.
Teradata has a SQL Statement :show table mytable;
This statement can return the definition of mytable.
But CRecordset class cann't run this SQL.
CDatabase can do it,but CDatabase.ExecuteSQL function has no return .
strSQL = "Show table mytable;";
set.Open(CRecordset::forwardOnly,(LPCTSTR)strSQL,CRecordset::none);//Error !
database.ExecuteSQL(strSQL);//OK,but how can I get the result?
How can I run this SQL and get the result?
Thanks.
|
|
|
|
|
willyfu wrote:
How can I run this SQL and get the result?
Getting the results from a stored procedure is not that difficult. One way of doing it is shown in MSDN article Q183001.
Here is another.
Here is a helpful discussion.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
finally,I found the ODBC API solution.
CString strSQL;
SQLLEN nRecCount,nFieldLen;
strSQL.Format("Show table mytable;");
CRecordset set(&database);//Create a CRecordset object
SQLExecDirect(set.m_hstmt,(SQLCHAR*)strSQL.GetBuffer(strSQL.GetLength()),strSQL.GetLength());
SQLRowCount(set.m_hstmt,&nRecCount);
for(int n = 0;n < nRecCount; n++)
{
SQLFetch(set.m_hstmt);
SQLGetData(set.m_hstmt,1,1,str1.GetBuffer(32000),32000,&nFieldLen);
str1.ReleaseBuffer();
}
that's all.
|
|
|
|
|
While it may work, this is a very odd use of a CString object. I'm curious why you are using a CRecordset object if all you need access to is its m_hstmt member.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have a prjt which compiles without errors, but keeps displaying an error message on execution. The error message is only supposed to appear when a certain variable x, is less than or equal to zero. Only one function calls the function that contains this error message. Even after "ensuring" that x has a postive variable, I still get the error message on execution.
My fxn which contains the error message is as follows:
<br />
void ei(double *x, double *expi, int nSize)<br />
{<br />
enum{nSize = 100};<br />
const int MAXIT = 100;<br />
const double EULER=0.577215664901533;<br />
const double EPS=1e-20;
<br />
<br />
<br />
int k;<br />
double fact[nSize], prev[nSize],sum[nSize],term[nSize];<br />
<br />
for(int t=0;t<nSize;t++)<br />
{<br />
if (x[t]<=0.0)<br />
{<br />
AfxMessageBox("x value incorrect, in ei!", MB_OKCANCEL|MB_ICONSTOP);
exit(1);<br />
}<br />
<br />
if (x[t]<EPS)<br />
{<br />
expi[t]=log(x[t])+EULER;
}<br />
<br />
if (x[t]<=-log(EPS))<br />
{<br />
sum[0]=0.0;<br />
fact[0]=1.0;<br />
<br />
for (k=1;k<MAXIT;k++)<br />
{<br />
fact[t] *= x[t]/k;<br />
term[t]=fact[t]/k;<br />
sum[t] += term[t];<br />
if (term[t]<EPS*sum[t]) break;<br />
}<br />
<br />
if (k>MAXIT)<br />
{<br />
AfxMessageBox("Series failed in ei!",MB_OKCANCEL|MB_ICONSTOP);<br />
exit(2);<br />
}<br />
<br />
expi[t]=sum[t]+log(x[t])+EULER;<br />
}<br />
<br />
else<br />
{<br />
sum[0]=0.0;<br />
term[0]=1.0;<br />
<br />
for (k=1;k<MAXIT;k++)<br />
{<br />
prev[t]=term[t];<br />
term[t] *= k/x[t];<br />
<br />
if (term[t]<EPS) break;<br />
<br />
if (term[t]<prev[t]) sum[t] += term[t];<br />
<br />
else<br />
{<br />
sum[t] -= prev[t];<br />
break;<br />
}<br />
}<br />
<br />
expi[t]=exp(x[t])*(1.0*sum[t])/x[t];<br />
}<br />
}<br />
}
the only place where the above function is used is:
<br />
void unbound(double *unbd, int nSize)<br />
{<br />
enum{nSize = 100};<br />
double A[nSize],B[nSize],k0[nSize],k1[nSize],s[nSize],expi[nSize],a[nSize],b[nSize];<br />
<br />
s[0] = 1;<br />
for (int t=1;t<nSize;t++)<br />
{<br />
double x;
<br />
CKuchukDlg MyClas; <br />
MyClas.m_dWellRad = x;<br />
<br />
void bessk0(double *x,double *k0,int nSize);<br />
void bessk1(double *x,double *k1, int nSize);<br />
void ei(double *x, double *expi, int nSize);<br />
<br />
s[t] = 2*t*PI;<br />
a[t] = x*sqrt(s[t]);<br />
b[t] = 2*sqrt(s[t]);<br />
<br />
bessk0(a,k0,nSize);<br />
bessk1(a,k1,nSize);<br />
ei(b,expi,nSize);<br />
<br />
A[t] = k0[t]/(x*sqrt(s[t])*k1[t]);<br />
B[t] = (1-exp(-2*sqrt(s[t])))/(2*sqrt(s[t]));<br />
<br />
unbd[t]=0.5*(A[t]-B[t]-expi[t]);<br />
}<br />
}<br />
could someone please tell me where im missing it? Thank you!
|
|
|
|
|
I need someplace where I can filter all application messages of the application (main window and all child windows and dialogs).
|
|
|
|
|
Look into SetWindowsHookEx
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
Hi guy!
I am formatting html tags from my vc application. I need to print tickets in each page separatedly. Do we have any tags for page break. So that each ticket is printed in a separate page! I would be grateful if anybody can help!
Thanks.
|
|
|
|
|
I'm not sure if this will help, but:
You may want to look into the css attribute page-break-before . I think that's it...
HTH
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
Hi All,
I am using static control on a dialog box in MFC.The text which is to be shown in the static control is to big to fit in it so its gets crop (half text displayed).Is there any way by which i can acheive text wrapping in the static control?
Thanks
Pushkar
|
|
|
|
|
The text is automatically wrapped in a static control. Increase the rectangle size vertically in the resource editor.
You can try to do that at run-time too and for that you will have to increase the static box size w.r.t the number of possible lines.
|
|
|
|