|
GetPrivateProfileString is EVIL. As you have found out, it has severe restrictions on 9X. It won't work at all if your INI file gets bigger than 64K.
It is not that difficult to write your own file routines to read an INI file, line by line, and do whatever you want with it. That's the approach I would use.
You can pick your friends, and you can pick your nose, but you can't pick your friend's nose.
|
|
|
|
|
this is not a soln. to ur problem. infact i'm askin for some help.
i'm also storing the passwords in ini files, but i've no idea how to encrypt and decrypt in my prog.
can u share some code with me
thanx and regards
|
|
|
|
|
Hi,
I am developing an MFC application on VC++ .Net with HTMLHelp generated by the AppWizard. I am looking to have context-sensitive help, much of which was generated by the wizard, but I find I have to add bits regarding menu options or toolbar options I have added on later.
I have invoked the help as follows:
ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp)
I have included the helpfiles for each option in the HTMLHelp project file alias:
ID_LPS_DELETE = hid_record_delete.htm
I have included their definitions in a header file HTMLDefines.h:
#define ID_LPS_DELETE 32792
I have included the header file in the map section of the project file:
[MAP]
#include HTMLDefines.h
With all of the above I am looking to have the help window come up automatically showing the correct Help page when you drag the Help icon onto a menu option, or press F1while highlighting a menu option. But I just get a message saying "Failed to launch Help".
What am I doing wrong??? All help appreciated,
Trimtrom
|
|
|
|
|
I have derived a class from fstream and my problem is that I can't write after I've read from the file.
My class looks like this:
class CLogBook : public fstream
{
public:
CLogBook();
~CLogBook() { close(); };
void SaveLogData();
void ReadLogData(string&);
int& ErrorCode() { return m_errorCode; };
string& ErrorMessage() { return m_errorMessage; };
string& Extra() { return m_extra; };
private:
string m_errorMessage;
int m_errorCode;
string m_extra;
};
SaveLogData() just formats a string and calls write(...) .
ReadLogData look like this:
void CLogBook::ReadLogData(string& data)
{
data.clear();
seekg(0);
while(!eof())
{
char* temp = new char[1024];
getline(temp, 1024, '\n');
data.append(temp);
data.append("\n");
delete [] temp;
}
}
and my test code looks like this:
CLogBook dummy;
dummy.open("test.txt", ios_base::in | ios_base::out | ios_base::app);
dummy.ErrorCode() = 123;
dummy.ErrorMessage() = "Error occured in your brain.. please RTFM!";
dummy.Extra() = "WinMain";
dummy.SaveLogData();
string buf("");
dummy.ReadLogData(buf);
MessageBox(NULL, buf.c_str(), "", MB_OK);
dummy.ErrorCode() = 666;
dummy.ErrorMessage() = "never written words";
dummy.Extra() = "BASIC SUCKS";
I hope I've got everything here... hope you can help!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I thought an fstream should be closed for reading before you try to write to it. I could be wrong, of course...
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
I tried this:
CLogBook dummy;
dummy.open("test.txt", ios_base::in | ios_base::out | ios_base::app);
dummy.ErrorCode() = 123;
dummy.ErrorMessage() = "erro error error";
dummy.Extra() = "WinMain";
dummy.SaveLogData();
dummy.close();
dummy.open("test.txt", ios_base::in | ios_base::out | ios_base::app);
string buf("");
dummy.ReadLogData(buf);
MessageBox(NULL, buf.c_str(), "", MB_OK);
dummy.ErrorCode() = 666;
dummy.ErrorMessage() = "yadda yadda";
dummy.Extra() = "Linux";
As you can read from the comments, it didn't work...
I must be somewhere else or what have I done wrong.... am I using the fstream wron or what?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Try calling clear() before attempting to write.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
nope...
I've also tried flush() with no success...
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
The following piece of code, modelled after yours, does write everything as intended:
#include <fstream>
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
class CLogBook : public fstream
{
public:
CLogBook(){}
~CLogBook(){ close(); }
void SaveLogData()
{
clear();
write(ErrorMessage().c_str(),ErrorMessage().size());
}
void ReadLogData(string& data)
{
seekg(0);
while(!eof()) {
char* temp = new char[1024];
getline(temp, 1024, '\n');
data.append(temp);
data.append("\n");
delete [] temp;
}
}
int& ErrorCode() { return m_errorCode; };
string& ErrorMessage() { return m_errorMessage; };
string& Extra() { return m_extra; };
private:
string m_errorMessage;
int m_errorCode;
string m_extra;
};
int main()
{
CLogBook dummy;
dummy.open("test.txt", ios_base::in | ios_base::out | ios_base::app);
dummy.ErrorCode() = 123;
dummy.ErrorMessage() = "Error occured in your brain.. please RTFM!";
dummy.Extra() = "WinMain";
dummy.SaveLogData();
string buf("");
dummy.ReadLogData(buf);
MessageBox(NULL, buf.c_str(), "", MB_OK);
dummy.ErrorCode() = 666;
dummy.ErrorMessage() = "never written words";
dummy.Extra() = "BASIC SUCKS";
dummy.SaveLogData();
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Aah!
Now I see what you meant... thanks, it works now!
ps. Would you/anyone be nice and tell me what you think of the class design?
it's not a big class but anyway!?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
One last qestion for now In VC++6 I have a MFC App that is a dialog based application that I have added a menu to. All of these menus have the mnemonics added in the caption &File E&xit... But none of these show up when the program is run. Is there something basic I am forgetting to do or set? It's under Windows XP so I don't know if that makes a difference or not.
Thanks for any info!
|
|
|
|
|
Under the display settings for Windows XP there is an option (on by default) which hides the shortcut keys until you hold down the Alt key.
Dave
|
|
|
|
|
Thanks, Thats weird that I never noticed it until I was working on my own app. Oh well thanks for the info!
|
|
|
|
|
I'm trying to figure out how to sort the date based on the short date format.
ie yyyy mm dd and dd mm yyyy. Any ideas.
Thanks
|
|
|
|
|
Make both YYYY MM DD, in crude pseudo code
wsprintf(szBuffer, "%04d%02d%02d", yyyy,mm,ddd);<br />
lDate = atol(szBuffer; )
The smalest number is the earliest date, the largest is the latest date. Or using M$ convert to COleDateTime format
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Does anyone have or know where I might be able to find like a quick reference card of shortcuts for VC++6 It would be really handy to have so I didn't know if there's one out there. I don't know if one comes with it cause we just have a site license at work so I don't have any manuals in front of me.
|
|
|
|
|
Help -> Keyboard Map
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I an application I am writing, I created several floating dialog bars. The problem is, that they all have the same title in the title bar. How can I create multiple floating Dialog Bars that have different titles?
-- Steve
|
|
|
|
|
CDialogBar bar;
bar.SetWindowText("My title");
I would expect it to be that simple. Tell me if not.
~RaGE();
|
|
|
|
|
I thought that it would be simple like that too. It just named all the floating dailog bars whatever I typed in the last time I called SetWindowText().
-- Steve
|
|
|
|
|
Hiya what is the way best to completely clear a text file so I can use it again and again??
Also how do I display the date "230303", reading it from the system??
Thanks,
grahamoj.
|
|
|
|
|
To clear a file
<br />
FILE* file;<br />
file = fopen("YourFile.txt", "w+");
Probably not the best way, but it works for me.
Kevin
|
|
|
|
|
You can use the strftime function to format a time/date string or you can use GetSystemTime to get the current time and date from the system.
|
|
|
|
|
I need somebody more litirate than I am to tell how to use some MFC classes in my program, but not creating the MFC project.
I was surprised by the following fact. Then I wrote a simple program which were using CAsyncSocket, and SocketInit() function everything was working Ok (I have choosen "Use MFC as shared Dll" in my Project Settings). After, I have decided what it's enough to do the job what is allready done. So, I have found the CPop3 class on CodeProjecta.com. This class uses some other MFC classes so I have done everything like in previous case. But as result I have recieved the error in AFXV_w32.H which required usen't windows.h MFC applications. I'm not able to find a place in the program where this header is included, and I think I won't be able. But this is not important. It's important if somebody expirianced will learn me how to use some suitable MFC classes in my program, would explain me how MFC is working (may be some books or links)
Need your help!!!
|
|
|
|
|
May I get handle of the resource (bitmap or icon) by his name and not his ID.
For example,
HBITMAP hBitmap = GetBitmapFromResource (_T("IDB_BITMAP1"));
If it possible then how can I do it?
Best regards,
Eugene Pustovoyt
|
|
|
|