|
You can also use resources to embed text file into your project.
Say the name the text file is data.txt, then in the .rc file add
IDS_TEXT_DATA RCDATA DISCARDABLE "Data.TXT"
and in the resource.h give assign appropriate constant to it
#define IDS_TEXT_DATA 5555
|
|
|
|
|
That's it!
The only answer that actually answers the question as posed. While the other answers achieve (roughly) the same functionality, this is the only answer I'd be satisfied with if it were my question. Nice work.
What if the text file is 2000 lines long and created by some other program? The other answers will all require more work.
Admittedly the values will be stored as text, rather than binary - a size penalty, though otherwise this would be my preferred approach.
There are pros and cons to each method. Whom are we to assume that we understand the relevance of each of these to the project in question? Let alone give a response that doesn't answer the posed question...
|
|
|
|
|
The only fear I have is of security.
If the developer intends to store security critical information in this text file, then I think he is inviting trouble from the hackers/crackers or what ever, as the resource file is wide open for extraction and manipulation.
Like pointed rightly by you, it's up to the OP to chose the method 
|
|
|
|
|
It really doesn't make much difference. In fact, with encryption this method could be more secure (difficult and time consuming to reverse - though one can still find/rip and use the decryption function as supplied in the exe along with the encrypted text).
There might be a difference of 5-10 mins in understanding the binary data as opposed to the (plain) text version using OllyDbg or (preferably) IDA Pro Advanced.
However, I don't see security as a consideration (nor was it mentioned) when storing colour values. :shrugs:
|
|
|
|
|
Hello Friends
Thanks EveryOne For their thoughtful consideration for my question.
But still I didnt Get my Answer.
Till Now, i am reading the file from disk and stroing it into Color Arrays.
Directly,i cant assign my RB Values to ColorArray as my File is Having more than 2000 lines and it can be changed later on As it is produced from Third party.
And Now,I dont want to keep this file on Disk for Security purpose even.
AS i Think,Would it be preferrable If i save color text file into Header file and add it into project and is ther any some way to get data into Structures by using CStdioFile or Some other way ?
Any Other Ideas ??
Thanks & Regards
Yogesh
|
|
|
|
|
Then Lakamraju's answer for you was perfect - The 2rd party just makes a file, which you refer to from your rc resource, and it gets built it.
This is less easy that the previous answers to work with, but it satisfies the requirements you've just written (and should have written in the original question - none of us are psychic. Well, maybe Carlo...)
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Hello
If i Use it like to embed in resource then My Question is that then Do we need text file on Disk when I use exe at other place ?
Regards
yogesh
|
|
|
|
|
Resources are built into the executable.
You don't need an icon file for your executable to have an icon at another place either.
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Thanks Carlo.
Regards
Yogesh
|
|
|
|
|
CFileVersionInfo fvi;
char szVer[ 512 ] = { 0 };
if( fvi.Open( _T( "Econovent.dll" )))
{
::wsprintf( szVer,
_T( "%d.%d.%d.%d" ),
fvi.GetFileVersionMajor(), fvi.GetFileVersionMinor(), fvi.GetFileVersionBuild(), fvi.GetFileVersionQFE() );
fvi.Close();}
It works perfect in win32, But when complied in x64 the "wsprintf", stops working. Are the a better solution that works in x64 and win32 at the same time.
I understand that i have change. I have tried but then its not working in win32 mode.
The code need to be old C-style version. I'm not native C/C++ i'm just trying to fixa a "bug".
|
|
|
|
|
jn4u@msn.com wrote: the "wsprintf", stops working.
You need to provide some more information, as this does not give any clues as to what may be happening. Try using your debugger to step through your code and see exactly what values are being returned from the function calls.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
Use
GetLastError() method after you called wsprintf and provide the error code
|
|
|
|
|
When compling in platform win32 works. Whan compile in x64.
cannot convert parameter 1 from 'char [512]' to 'LPWSTR'
in the wsprintf call first parameter szVer.
Understand that de definition "change" för char in the call or
I have tride windhows.h and TCHAR.
|
|
|
|
|
check your build settings. you probably have "Multi-byte" or "Unicode" set for "Character set" on the x64 build, but "not set" on the x86 build.
|
|
|
|
|
Thank you.
I missed that on my project. It’s work perfect.
Some of my collage at work pointed out that change to “std::string” in the project. But still the interface to dll need to be native C with c-style string. Is std::string more neutral to the character set?
Comming from Delphi to C# world then C/C++ for this project lot of reading "new" things. My old Charles Petzold book is back on the self again. ;D
|
|
|
|
|
jn4u wrote: Is std::string more neutral to the character set?
sadly, no. there is a std::wstring variation to handle wide char strings.
|
|
|
|
|
Can i change the code copy to the szVer in a better way that does not use wsprint. Just want the format.
xx.xx.xx.xx
|
|
|
|
|
You should use TCHAR for your array and _stprintf() to fill it. In that way you can compile for ANSI or Unicode without the need to change your source.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
|
|
|
|
|
Is there a way to prevent the user from logging off from their Windows account while my application is running?
|
|
|
|
|
Is WM_QUERYENDSESSION of any help?
"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
|
|
|
|
|
Yea thanks, I had forgotten about that mesage and it did the trick.
Thanks again 
|
|
|
|
|
Method for XP or earlier is slightly different from Vista/Win7 from my experience.
For XP or earlier, return 0 for WM_QUERYENDSESSION and this should be enough.
For Vista/Win7, I haven't found a way to entirely stop logging off. But temporarily blocking logging off is possible. I would return 1 for WM_QUERYENDSESSION and register a blocking reason during WM_ENDSESSION, by calling ShutdownBlockReasonCreate. Then call ShutdownBlockReasonDestroy when your application is finished running.
You should obey the description mentioned in WM_ENDSESSION Message[^] and WM_QUERYENDSESSION[^] to make sure both user and Windows system are happy.
|
|
|
|
|
Are you paying for their computer?
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
He he, no but the PC is running an important control system that the normal user is not authorised to shut down. However, if the user logs off, it closes my application.
|
|
|
|
|
Hello all,
How do you get a list of all files and folders of ALL types including system and critical ones, and files even in archives on a specific drive, and to put this string on a richtextbox or textbox.
Simple Thanks and Regards,
Brandon T. H.
Been programming in Visual Basic for 4 years this point forward, and is very good at it (I can even create programs completely on code, without dragging those items from the toolbox). Programming C++ for 1 year so far and the same with C#.
Many of life's failures are people who did not realize how close they were to success when they gave up. - Thomas Edison
|
|
|
|