|
True, but if the name were not obvious, would the person know what to do with it even if they managed to make a copy of it?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Yes but I need some more fail proof than that.
Nemok
|
|
|
|
|
a little Googling is enough to convince me that it is not a simple task.
you might take a look at UPX (available from sourceforge). i think it can do this.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Hi,
It is possible to load a binary, executable block of raw data into memory and link a function to it. So you could call that 'extra' function from your code without any problem. Maybe this is what you need ??
But to load an entire file into memory and to run it that is something different.
codito ergo sum
|
|
|
|
|
Actually yes I need to load an entire file and run it. Any ideas?
Nemok
|
|
|
|
|
Are you looking to just load dlls, or run the actual exe from memory? I've been working on virtual files system similar to thinstall, but am far from finishing. However, I do have some code that will load a dll from memory with certain limitations. Just depends on what you exact needs are.
--
Joel Lucsy
|
|
|
|
|
Hello,
I've encountered a strange problem when I use the const_cast() operator. See the following code that behaves strange:
std::stringstream sstrMsg;
char* pszMsg = const_cast<char*>(sstrMsg.str().c_str());
SPrintBuffer(&pszMsg);
I've checked the return values of both stringstream::str() and std::string::c_str() . They both return the expected data. Strangely enough, after the cast, pszMsg points to some undefined memory address. (The address pointed to holds the value -18).
I'm currently using the following workaround:
char* pszMsg = new char[sstrMsg.str().length()];
strncpy(pszMsg, sstrMsg.str().c_str(), sstrMsg.str().length());
SPrintBuffer(&pszMsg);
delete[] pszMsg;
Does anybody have a clue why const_cast is producing undesired results?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi,
If you mean the const_cast casting operator, I believe you have used it wrong. It should be used like this:
char* pszMsg = const_cast<char*>(sstrMsg.str().c_str());
This shouldn't give any problems.
codito ergo sum
|
|
|
|
|
Hello,
I used it just like you said it should be used. It's just that the '<' and the '>' 'disappeared' because I didn't use '<' and '>' respectively. Sometimes the parser for the message removes those in pre tags and sometimes it doesn't.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Your code looks very dangerous.
Q1) Why would you need to cast away the constancy of the pointer returned by c_str() ?
How about using: const char* pszMsg = sstrMsg.str().c_str();
Q2) Why would a function named SPrintBuffer() need a pointer to a pointer of type char* ?
The name implies that it is just going to print out the contents of the buffer, not modify it.
Note: Modifing the data return via c_str() , is a very bad idea.
INTP
Every thing is relative...
|
|
|
|
|
I know that the code looks very dangerous. I double checked the code for SPrintBuffer() and it doesn't modify the string.
The reason that the reason the function takes just a char* and not a const char* is unknown to me. I need to add a link layer of a protocol to a program that my teacher wrote. Please don't tell me, the entire program is badly designed and all the code looks like spaghetti... If you want to see some obfuscated C code, this program is right for you!
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Sorry I have been gone for a few days.
1) It sounds like your teachers code would not pass a review by me, let alone a quality assurance team.
If the function does not modify the data pointed to by the argument, then you should say so by making it a pointer to constant data.
2) You still should not need to use const_cast , instead you can just call the function like so: SPrintBuffer((char*)str.c_str()); .
Note: The const_cast should not be needed in this particular case.
Note: In your original code you are trying to pass a char** and not a char*
|
|
|
|
|
John R. Shaw wrote: Sorry I have been gone for a few days.
So have I...
John R. Shaw wrote: 1) It sounds like your teachers code would not pass a review by me, let alone a quality assurance team.
That was my first thought and I offered to rewrite the entire program instead of doing all the other assignments. This was a no-go since the course is not going to be given anymore.
Anyway, that's the way we learn things in college these days..
John R. Shaw wrote: 2) You still should not need to use const_cast, instead you can just call the function like so: SPrintBuffer((char*)str.c_str());.
I force myself to use straight C++ only. The C-Style casts are there fore backwards compatibility. They shouldn't make a difference. I'll try it and let you know if there it will work.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Looking for GUI simple tutorial with VC++ .NET version 7.1
I am a newbie in this product. I would like to have a GUI simple tutorial for VC++ version 7 using with MFC (such as click on button then get result of addition of 2 numbers or display a note on edit box. I downloaded 1 sample from www.msoe.edu/eecs, but it for older version then I was stuck in the middle instruction (due to ClassWizard could not be found). I found microsoft VC++ devepment tool is very very hard to learn.
Please advise me a good book about MFC and GUI for beginner.
I am a hardware guy, so I like GUI to interface with devices and instrument.
Thanks.
MilkyWay
MilkyWay
|
|
|
|
|
Loc Milkyway wrote: I found microsoft VC++ devepment tool is very very hard to learn.
Well, C++ is a difficult language and Visual C++ is an intimidating environment! Other languages, such as VB and C# are far easier for doing GUIs.
Anyway, I took a peek at this site and it looks quite good.
http://www.functionx.com/visualc/[^]
If you click on the "Introduction to Applications" link in the top left it takes you into a tutorial in which they occasionally tell you how to do it if you're using VC++ 6 and how to do it in VC++ 7.1. You will also see VC++ 7.1 IDE screenshots in various places.
Instead of ClassWizard you have to use the Class View and Poperties windows. See here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcgrfWhereIsClassWizardInVisualCNET.asp[^]
Kevin
|
|
|
|
|
Kevin ! Thank you... thank you very much. www.functionx.com is the cool site for me.
MilkyWay
|
|
|
|
|
Hi,
I'm currently creating a lot of ownerdrawn MFC-controls. Can anybody tell why i should use DrawItem() instead of OnPaint()?
|
|
|
|
|
for many controls, DrawItem will give you information about the specific sub-item (menu choice, list box item, etc) that you need to draw. OnPaint is for the control as a whole.
for controls that don't have sub-items, there's not much difference between the two (buttons, etc)
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Chris Losinger wrote: for controls that don't have sub-items, there's not much difference between the two (buttons, etc)
For buttons, DrawItem provides provides a lot of info that OnPaint does not, such as selection and focus state, and whether the button is up, down, disabled, ect.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
|
good morning,
anybody has experience with this? the report is txt file, everything looks just fine, but when send it to print, between some pages it would print blank pages, it didn't miss any info, but between 2&3, 3&4, 4&5 it "insert" empty page into. I have check the form feet and everything on txt file, it looks fine.
here is the print job:
if ( nPageNo > 1 )
m_Rpt->rptMessage( "\f" ); // form feed...
m_Rpt->rptMessage( m_strOrientCPI );
//do line drawings, detail headers, etc.
if ( nFirstGrpChg != -1 )
{
checkForNewPage( true );
drawBottomLine();
doDetailSummary();
drawBottomLine();
checkForNewPage( false, nFirstGrpChg );
if ( m_nCurrentPageLine == 0 )
doHeaders();
else
{
//if not a new page, still need a seperator line
fprintf(pf_rptlog,"\n" );
m_nCurrentPageLine++;
}
//call formatData here to correct witdth after footer and headers
strOut = formatData( pszData, delimiter, 0, true );
while( nFirstGrpChg < m_nDrillDownLevels )
{
drawTopLine( ( nFirstGrpChg + 1 ) );
fprintf(pf_rptlog,"%s\n",doBoinks( vholdDataHdr[nFirstGrpChg], (nFirstGrpChg + 1) ).c_str() );
m_nCurrentPageLine++;
nFirstGrpChg++;
}
drawTopLine();
doDetailHeader();
drawMiddleLine();
}
else
{
checkForNewPage( true );
if ( m_nCurrentPageLine == 0 )
{
doHeaders(); //include firstpages stuff in here
nFirstGrpChg = checkGroupHeaders( vholdDataHdr, pszData, delimiter );
loadFormat( m_currentFmt ); //this will set correct with for first grp on first page
strOut = formatData( pszData, delimiter, 0, true );
if ( nFirstGrpChg != -1 )
{
while( nFirstGrpChg < m_nDrillDownLevels )
{
drawTopLine( ( nFirstGrpChg + 1 ) );
fprintf(pf_rptlog,"%s\n",doBoinks( vholdDataHdr[nFirstGrpChg], (nFirstGrpChg + 1) ).c_str() );
m_nCurrentPageLine++;
nFirstGrpChg++;
}
}
drawTopLine();
doDetailHeader();
drawMiddleLine();
}
else
{
strOut = formatData( pszData, delimiter, 0, true );
}
}
m_bFirstGrpLine = false;
if ( m_nFrameGroup != -1 )
{
strOut = doBoinks( strOut ); //getBoink() + strOut + getBoink();
}
fprintf(pf_rptlog,"%s\n",strOut.c_str() );
m_nCurrentPageLine++;
if ( m_nCurrentPageLine == ( m_nPageLength - 1 ) )
doFooter();
|
|
|
|
|
Have anybody seen any examples or source code how to make toolbar for Outlook Express?
|
|
|
|
|
See Demo toolbar for OE
http://www.plugins-soft.com/demos.html
BUT this commercial source.
|
|
|
|
|
Hi I'm trying to do the following:
1) generate a random # from the array layer_array[]
2) swap the number generated with a negative number, to avoid repetition of that random #.
I'm not sure I'm correctly sampling from layer_array[]. And I'm definitely not implementing swap() correctly....how would i proceed?
Please help.
<br />
#include <cmath><br />
#include "stdafx.h"<br />
#include <ctime><br />
#include <cstdlib><br />
#include <algorithm><br />
#include <fstream><br />
#include <iostream><br />
#include <iomanip><br />
using namespace std;<br />
<br />
int main()<br />
{<br />
const int size = 20;<br />
<br />
int layer_array[size]={0};<br />
<br />
for(int i=0; i<size; i++)<br />
layer_array[i]=i+1;<br />
<br />
srand((unsigned)time(0)); <br />
<br />
int random_integer[size] ={0};
<br />
for(int index=0; index<size; index++)<br />
{<br />
random_integer[index] = (rand()%size)+1; <br />
swap(&layer_array[index],&layer_array[index*-1]);
<br />
cout << random_integer[index] << endl; <br />
}<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
aaadetos wrote:
swap(&layer_array[index], &layer_array[index * -1]);//error c2664
I'm curious what you are expecting to swap with this. You typically don't dereference an array using a negative number.
By the very definition of random, uniqueness is not a quarantee. Therefore, you can't get a random number that is guaranteed to not repeat. If you do, then it is not random. However, if you are simply wanting a list of unique numbers returned to you in a pseudo-random order, that is a different beast altogether.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|