|
How can I create a cfg file and read from or write on it?
Thanks for helping!
|
|
|
|
|
|
Further to Michael's answer, it depends on whether you want to use Windows .INI style config files, or XML config files.
For the former, take a look at the functions GetPrivateProfileString and WritePrivateProfileString, but note that using these APIs is not really encouraged, as they're intended for 16-bit compatability.
For the latter, look at using MSXML or use whatever your choice in XML parsers happens to be.
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
I'm going to use that in an MFC application to configure oracle connection. I want to use windows .INI style.
|
|
|
|
|
Thanks for your reply
I'm going to use that in an MFC application to configure oracle connection. I want to use windows .INI style.
|
|
|
|
|
Further to Michael's and Ian's replies, see this article if you want to use a custom binary format to read and write configuration data.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
*.CFG is not a standard used by MFC. MFC usually uses *.INI.
*.CFG is for .NET framework.
Below is the code for C# to access the *.CFG(refering MSDN)
Just change it to Managed C++
using System;
using System.Collections;
using System.Configuration;
class MyConfigurationReader {
public void ReadMySettings() {
IDictionary sampleTable = (IDictionary)
ConfigurationSettings.GetConfig("sampleSection");
string value1 = (string)sampleTable["setting1"];
string value2 = (string)sampleTable["setting2"];
string value3 = (string)sampleTable["setting3"];
}
}
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi!
I am trying to get the dimensions of the screen on my second monitor. I have included windows.h and multimon.h in my program but I always the error message that HMONITOR is an undeclared identifier.
Can anyone give me a hint at what I am doing wrong? Thanks!
Karen
|
|
|
|
|
|
I downloaded a VC++ source project from a original,but I don't build the project successfully,Why?
Let us rap off,for you,for me,for our man!
|
|
|
|
|
LoverOfVCpp wrote:
I downloaded a VC++ source project from a original,but I don't build the project successfully,Why?
I think you need to give us some details (like the error message in the output window, what it is you're trying to build, etc), because that (really vague) problem could have multiple causes:
* Project never built in the first place
* Missing libraries or other dependencies
* Intended for different version of VC++
* Incorrect compiler settings
* Corrupted files interfering with the build
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
Is it that the VC++ project is a later project version like VS.NET 2003 and yours are not?
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi all,
when i open the menu in the outlook (not express!) i have New->Appointment
if i select it a dialog is show with 2 tabs:
1. appointment
2. scheduling
i would like to insert my own tab between 1 and 2....how can i do that? can any1 show me code to do that?
also, i want to create a new item between appointment and scheduling....can any1 show me how to do that?
thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hello all, im trying to learn about implementing unicode support in my apps, but i cant seem to get it straight, heres a simple example:
//////////////////// test.cpp //////////////////////
#include <tchar.h>
#include <stdio.h>
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow)
{
HANDLE hmutex=CreateMutex(NULL, TRUE, _T("mymutex"));
if(GetLastError()==ERROR_ALREADY_EXISTS)
{
// allready up, so get outa here
return 0;
}
// use some string functions & write some txt to a file
TCHAR str1[50]=_T("string1");
TCHAR str2[20]=_T("string 2");
strcat(str1, str2);
FILE* pfile=fopen(_T("thefile.txt"), _T("w"));
if(pfile)
{
fprintf(pfile, _T("the full string is:%s"), str1);
fclose(pfile);
}
// Remove the mutex, so we can run next time
ReleaseMutex(hmutex);
return 0;
}
ibe added _UNICODE to the preprocesor definitions in project->settings, and when i complile, i get this:
Compiling...
test.cpp
d:\code\test\test.cpp(9) : error C2664: 'CreateMutexA' : cannot convert parameter 3 from 'unsigned short [8]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\code\test\test.cpp(19) : error C2664: 'strcat' : cannot convert parameter 1 from 'unsigned short [50]' to 'char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\code\test\test.cpp(21) : error C2664: 'fopen' : cannot convert parameter 1 from 'unsigned short [12]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:\code\test\test.cpp(24) : error C2001: newline in constant
d:\code\test\test.cpp(24) : error C2143: syntax error : missing ')' before 'string'
d:\code\test\test.cpp(24) : error C2664: 'fprintf' : cannot convert parameter 2 from 'unsigned short [22]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
test.exe - 6 error(s), 0 warning(s)
if i also define UNICODE (apart from _UNICODE), the error about CreateMutex() goes away, but not the other ones, its obvious that the char versions of these functions are being called instead of the wide character versions!.
i tought the whole point of using TCHAR and the _T() macros, was that if i decide to build my app with unicode support, i simply define _UNICODE, and if later i decide NOT to use unicode (if for example i target Win9x machines), all i would have to do is NOT define _UNICODE.
what im i doing wrong??
thanks!
|
|
|
|
|
Ernesto D. wrote:
what im i doing wrong??
What you're doing wrong is assuming that the standard C library understands Unicode the same way the Win32 API does. Win32 defines unicode and ascii versions of all APIs (ie, CreateMutex is actually a macro that maps onto CreateMutexA or CreateMutexW as appropriate).
The Standard C library implemented on Windows does have wide-character versions of fopen, fprintf etc (they're _wfopen and fwprintf) - look in MSDN. You may need to define your own macros to handle these seamlessly, but it's probably easier to use the Win32 API or MFC functions instead if you need unicode *and* ascii version of your application. I think there's a way of getting unicode support on 9X, but I can't remember how.
You might also want to read this article[^] on Joel On Software.
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
|
Aha!, now i see the trouble(s).
1.- i DO have to define both _UNICODE and UNICODE (bummer)
2.- im using the char versions of the standard string functions (strlen, strcat, etc), instead of the TCHAR versions of them (_tcscat, _ftprintf, etc.)
3.- i forgot to UN-define _MBCS (dough!)
just one more question.
reading MSDN, i noticed 2 versions of winmain, one for mbcs and one for unicode, so, is there a tchar version of it too? and, i havent changed the winmain to _twinmain or whatever and still the app compiles fine with unicode defined. so, do i have to change the entry point of the app to point to it? (ok its 2 questions).
thanks very much for your answers!
ps. Michael, your article on strings RULES! (as usual)
|
|
|
|
|
I want to save mails from inbox folder in msg files and inport into the inbox of another mail box. Please Help me.
|
|
|
|
|
Every time I execute an opengl application compiled under visual c++ 6.0 my PC suddenly shutdowns and restart.
I use visual C++ 6.0 under Windows 2000, but it is the first times I try to develop opengl applications ?
Can anybody help ?
Please help because I have no idea of what causes this crash : must I configure something before developping using opengl ? Is it possible there is a restriction on my computer that blocks any attempt to execute some code including opengl libraries ? Is there any known uncompatibility betwenn opengl and MFC ?
I'm really falling into despair because I cannot do anything with opengl at the moment.
for example I've tried the project "Getting Started With OpenGL" submitted by Amol Kakhandi on this site and when I try to execute the debug version with attached debugger, my PC crashes executing this line :
ShowWindow( hWnd, 1 );
into the WinMain function
Please help
|
|
|
|
|
a system crash doesn't have anything to do with the language u code something,
so this is not the right forum!
Don't try it, just do it!
|
|
|
|
|
Well did you play any opengl made games on your computer?
Well... I am a beginner ...
|
|
|
|
|
Sounds like a video driver bug. What video card are you using? Check that you're using the latest drivers from your video card manufacturer. If you are already using the latest drivers, it may be useful to make a minimal test case and report it to the manufacturer's developer forums.
- Mike
|
|
|
|
|
OpenGL is a open standard for all video card. So, I guess it should not be a cause of problem as compare to your video card drivers or your hardware.
Or worst, does your video card support OpenGL?
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Well my video card is an old one : voodoo3 AGP.
I'll look for the latest drivers, after all maybe that is.
But if you know common problems with this card (except the oldity) please help
|
|
|
|
|
PROBLEM SOLVED !
I was using beta drivers for my voodoo3 AGP video card
with the lastest drivers... no problem
Thanks for your help !
|
|
|
|