|
Hi,
I've used the following code to get all the section names from an ini file. But whats happening is, am getting only one section name. But the documentation for 'GetPrivateProfileSectionNames' says that that first parameter will contain a "Pointer to a buffer that receives the section names associated with the named file. The buffer is filled with one or more null-terminated strings; the last string is followed by a second null character."
The following is the code that i've used.
//--------------------------------------------------------------------------
StringBuilder temp = new StringBuilder(8192);
int nRetValue = GetPrivateProfileSectionNames(temp, 8192, m_strIniFilePath);
string strSectionNames = temp.ToString();
string[] strArrSectionNames = strSectionNames.Split(null);
//--------------------------------------------------------------------------
Any help would be greatly appreciated.
Thanks and Regards
Vikram Attiganal
|
|
|
|
|
I would imaging that when this is converted in to C# the StringBuilder is reading to the first null and then stops because it thinks it is the end of the string. Strings in C/C++ are null terminated.
What you will need to do is to go through your buffer and find all the nulls yourself and converting it to a string by pointing to the byte after the each null terminator.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
You would be "imagining" correctly!
GetPrivateProfileSectionNames (and I assume the original poster is P/Invoking this) fills a string buffer with NULL-delimited strings, with the last string having a second NULL terminator. This is actually pretty common with Win32 APIs when using string buffers with arra-like content (like the GetOpenFileName and GetSaveFileName APIs for the file type filters).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi
I successfully worked with Remoting Concepts. What my question is, how could we popup message in that remote application. Like Yahoo & MSN Messanger displayes "You have one new mail" then it continues. Like that, My remote server running in separate IP address, if any client that called the method in remote server, then it immediately popups up message like you are called from this person <their name="" or="" ip="">, then continues with the client.
Instead of popups if invoking separate form, it works but i should show the form as ShowDialog instead of show. If it could be showdialog then the client application waits until the form closed from the server. Its a problem for me if no one respond in server place, the client application waits.
I need some sort of solution on this, Thanks in Advance. I don't know this is the right way or we have some other way to intimate to the remote server that they receive some message. I need some possible solutions.
Chandru
|
|
|
|
|
|
|
I used this code for doin the samething...
ifstream(fp);
char buf[200];
fp.open("input.txt", ios::in);
fp.getline(buf,200,'\n');
this code reads first line in the file at a time and stores it into the array buf and increments the pointer to nextline. if u want u can use a condition like fp.EOF (end of file condition) or use a any loop to read line by line...
Hope this helps....
Good Luck
Suman
|
|
|
|
|
This is what we would call C++. You answered on the C# forum...
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
oops!... i am sorry ...yeah it is c++, presently i am workin on both simultaneously....so little bit messed up....anyway i hope we can implement on the same lines using C# headers in c#.
Suman
|
|
|
|
|
System.IO.StreamReader is the class you want. I suspect it has a ReadLine function, the StreamWriter certainly has a WriteLine function.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
This is so far what i have
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)<br />
{<br />
string file = openFileDialog1.FileName;<br />
StreamReader sr = File.OpenText(file);<br />
int j = 0;<br />
char[] tempo;<br />
char tempchar;<br />
while (!sr.EndOfStream)<br />
{<br />
array2[j] = sr.ReadLine();<br />
listBox1.Items.Add(array2[j]);<br />
tempo = sr.ReadLine().ToCharArray();<br />
for (int k = 0; k < 35; k++)<br />
{<br />
tempchar = tempo[k];<br />
array[j, k] = tempchar;<br />
}<br />
j++;<br />
}
|
|
|
|
|
And what happens ?
It seems to me that you'd be better off using a dynamic arraylist than a fixed array.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
it reads and and loads the array into a textbox, it loads two types of arrays but it seems to not load the multidimensional array incorrectly, i want one char in the array, actually int.
|
|
|
|
|
i just had to do that for a project i'm working on. this is what i came up with:
System.IO.StreamReader sReader;<br />
System.Collections.ArrayList textArray;<br />
<br />
sReader = new System.IO.StreamReader(filename);<br />
textArray = new System.Collections.ArrayList();<br />
while(true)<br />
{<br />
string line = sReader.ReadLine();<br />
if(null != line)<br />
textArray.Add(line);<br />
else<br />
break;<br />
}<br />
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
|
Doh!!
|
|
|
|
|
|
does one exist? i thought i remember seeing one somewhere...
would this be difficult to do yourself?
|
|
|
|
|
Yeah.. it exists and I am pretty much sure of it seeing somewhere over this forum. I think it is not that much difficult to do, but i am not having code to show. Try searching on this forum using "listview combobox", i am sure u can find some useful articles on it.
Good Luck.
Suman
|
|
|
|
|
Yes, it's very difficult to do if you're using the ListView defined in the BCL. That encapsulates the Windows Common Controls List-View. Drawing iconic headers and colored cells isn't too hard, but siting other controls requires quit a bit of work.
There are third-party controls, however, that do this. They are more analogous to the DataGrid , but provide all the functionality of both plus more. Infragistics[^] and Developer Express[^] are just a couple of the third-party component developers that have such controls.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
I was hoping to be able to create something similar to a traditional ActiveX control that can be embeded into a web page so that my customers can go to a web page and have my control help fix problems on their computer with embedable WinForm controls.
To my disappointment it appears the security on embeded WinForms is a little lacking. It doesn't prompt the user on wether they want to trust my control. It automatically doesn't trust it and gives it very minimal rights. If they want to be able to use my control they have to manually adjust the .NET security on their computer.
The problem lies in the fact my customers barely know how to turn on their computer let alone doing anything like adjusting their security permissions. Have anyone been able to create a .NET control that is embedded on a web page that prompts the user for trusted permissions. Similar to that of a traditional ActiveX control found on Windows Update and the like.
If this isn't possible, then is it at least possible to create an ActiveX control in .NET that will do what I want? Ugh I dread the thought of having to write anymore ATL COM in C++ since .NET is so much easier to maintain and develop.
- Drew
|
|
|
|
|
Previously I was an architect that designed and developed a massive N-tier application using embedded Windows Forms controls and touchlessly-deployed Windows Forms Applciation and not once did customers have to manually change their CAS settings. You wrap this in an install. I wrote an Installer derivative that enumerate the Machine policy (all the code necessary is defined in the BCL) and added (or removed upon uninstall) our UrlMembershipCondition . This was executed as a custom action from Windows Installer (using VS.NET's Windows Installer projects - while severely limited in support for MSI features - makes this possible very easily).
.NET CAS doesn't prompt the user because users often make uninformed and ill-choices, clicking "Yes" to everything they read. It's a much tigher sandbox than what ActiveX has - if you can even call that a sandbox.
If you want more information on embeddeding Windows Forms controls - and even supporting client scripting (that depends on IE ActiveX security settings), read an old article of mine at http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=388[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
This means you had a seperate link that ran an .msi installation and changed their security settings to trust your url and any code on the page? If that is what I understand, then it isn't really touch-less than, correct? I really didn't want the customer to have to do anything but visit the site. The custom control I am developing needs access to the registry and/or the ability to run processes on the client machine. If I have misunderstood what you are saying you did then please let me know. The only way I see it is I would need a seperate executable they would need to download and run that would automatically change their security settings to allow my code to run with all permissions. If it is really that easy to do I dont see it as being much more secure.
-
Drew
|
|
|
|
|
Truly touchless deployment requires that your control only do what it is allowed to do (in .NET 1.0 this was nothing; thanks to the requests of several of us early adopters of touchless deployment, .NET 1.1 grants the Internet_Zone some permissions). There's simply no way around that (it's like being able to force installation of your ActiveX controls on unsuspecting clients - that's bad).
In .NET 2.0 there will be a technology called ClickOnce[^] that can save you from writing your own installation routine, but this won't be truly touchless either. It should - assuming no further changes - prompt the user to install an application and can update that application. The assemblies, however, are not downloaded in the same manner (i.e., automatic updates when IEExec checks for new versions of assemblies from their respective codebases).
There's just no getting around it: you can't force yourself on users; the framework won't allow it. If it did, then someone with malicous intent could force their malicous code on users, too.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|