|
Hi,
How could I get all the section names in an ini?
I know the below.
dwLen = GetPrivateProfileString( NULL, NULL, lpDefault, lpResult, nSize, lpFileName );
It will store all the section names to lpResult. But how can I estimate the nSize, when I am unknown about the section name count and size?
I have to find the nSize first, to allocate the memory for lpResult sothat I can get all the section names. What would be the solution?
Thank you.
- NS -
|
|
|
|
|
|
Nothing is there related to my context...
It is for simple read and write...
- NS -
|
|
|
|
|
|
Three remarks:
1. GetPrivateProfileString is usually used to handle one entry at a time, which entry you of course know the size of.
2. For entries which have no fixed size (strings), you can take a default size for your buffer (MAX_PATH ?) or you can associate another key of size integer which contains the size of the string.
3. Same for keys that contain various amount of subkeys (like most recent used lists, and so), you usually store a parallel key containing the amount of keys to read.
So, if the information has been written properly, there should be a key containing the size you are needing.
If not, you are probably trying to read too much at a time and need to read the keys recursively.
A dirty trick to achieve what you are trying to do, is to do a loop in which you check the returned value dwLen against the buffer size nSize. Increment nSize until it is different from dwLen, in this case you are sure that everything has been read properly. Something like (this is pseudocode):
while (sizeread >= nSize)
{
nSize+=1024
sizeread=ReadKey(nSize)
}
This snippet obviously does not work, but I think you can get the idea.
~RaGE();
|
|
|
|
|
I understood... but what i need is:
An ini file contains a lot of sections and keys.
I have to get the section names' list.
GetPrivateProfileSection(...) will return all section names as a null seperated list. Actually I need to get the length of this list.
This ini file is from an out side source, so I cannot expect the section names' count or size.
In this situation one method that I think to do is specify a very higher size ( about 32K ).
Could you please tell me your opinion about this?
Thank you.
- NS -
|
|
|
|
|
NS17 wrote: In this situation one method that I think to do is specify a very higher size ( about 32K ).
Could you please tell me your opinion about this?
This is very memory consuming. I would suggest to use my second method: Read in the key names using ::GetPrivateProfileSectionNames ( this give you only the names, with which you can retrieve the keys later) as long as the return value is equal to the size of your buffer minus two, and increase dynamically the size of the buffer at each step.
MSDN quote : If the buffer is not large enough to contain all the section names associated with the specified initialization file, the return value is equal to the length specified by nSize minus two.
~RaGE();
|
|
|
|
|
Ok... Thank you...
But what about the performance? I have no idea about how windows handles ini files...
- NS -
|
|
|
|
|
NS17 wrote: I have no idea about how windows handles ini files...
Ini files are now obsolete, replaced by entries in the registry. It was a normal text file, read in as a normal text file, and keys were searched for using normal string search functions.
Performance of course will highly depend on the size of your file and the number of entries in it. If you see that it requires too much run to get the approximative good size, increase the the size in each loop with higher size steps.
~RaGE();
|
|
|
|
|
Yes... fine...
Thank you very much!
- NS -
|
|
|
|
|
I actually like .INI files. Place an .INI file with settings in the application folder and you don't have to worry about orphaned registry entries when the application folder is deleted. If I'm writing a program I aim, within reason, to make it installable simply by copying files, uninstallable by simply deleting them and no littering of the system. Obviously this is not always possible or economical but it's a good aim as users, especially "non-expert" users, often try to uninstall an application by deleting the application folder.
Steve
|
|
|
|
|
You said it...
I am also like to do the same...
- NS -
|
|
|
|
|
NS17 wrote: I have no idea about how windows handles ini files...
While it is true that they are just text files, an API exists for reading from, and writing to, them. See the functions near the bottom of this link.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Rage wrote: This is very memory consuming.
32KB is very memory consuming? Since when? Anything less than 1MB is trivial.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
NS17 wrote: It will store all the section names to lpResult. But how can I estimate the nSize...
Just allocate several KB and you'll be fine.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Does the GetEffectiveRightsFromAcl() function return the effective permission of a trustee by combining the ntfs permissions and the share level permissions?
Kelvin Chikomo
|
|
|
|
|
how can create exe file from my application
I use visuall c++.net
Thank you
|
|
|
|
|
If you are sure that it is an EXE project, then click build to build the executable file.
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
I know click build to build
thank you but I will create exe file from my application
I was create application
I work with visuall c from 4 years ago
|
|
|
|
|
When you build your project, the exe file is automatically generated. If you are in debug mode, look in the debug folder (in your porject folder) and if you are in release mode, look at the release folder. Your exe should be there (unless you have specified another directory for the executable file in your project settings).
|
|
|
|
|
|
Sorry but I don't understand what you are trying to say
Is it ok for you now or do you still have another question ?
|
|
|
|
|
What does it have to do with creating an exe ???? It is completely different from your first question
If you want to load 3dmax files in C++, you'll have either to code it yourself (long work I think) or use some external libraries. What is exactly the purpose of what you are trying to do ? Is it for a 3D game ? If yes, I strongly suggest you to look for specific rendering engines like Ogre[^], Irrlicht[^], ...
|
|
|
|
|
VisuallC wrote: No answer I want a picture into exe file ok
Maybe if you asked how to do it you would have had an answer but we cannot gues what you are looking for. Be more explicit.
Now, if you want to display a picture (I think this is what you are looking for) in your program, first how do you want to display it ? Again, if it is still in a "game-oriented" fashion (that is full screen mode and this kind of things), you'd better go for one of the rendering engine I suggested you. Otherwise you'll have to work woth the .NET framework (sorry, but I don't have a lot of experience in that).
So, you want to do a game and your questions are related to that ? Is that correct ?
Please, try to be more explicit because explaining your problem in 2 lines is a little bit short... I know english is not your mother tongue (for me also) but otherwise you will never get a clear answer to your problem.
|
|
|
|
|
VisuallC wrote: I was created application
What exactly does this mean? Are you wanting to create an applicaton, or have you already created the application and now you want to do something else?
VisuallC wrote: Now Output application in exe file
Was a .exe file created as a result of the build process? If so, what is the question?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|