|
You can Impersonate current user with admin. For how to do it chech WindowsIdentity.Impersonate() in MSDN
Mazy
No sig. available now.
|
|
|
|
|
what would be the best way to store user settings, i.e. window locations, options, etc. would i use .ini files, the registry, or something else?
thanks,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
Have you considered using Application configuration files(yourapp.exe.config) or using isolated storage. I think isolated storage support per user settings.
Regards,
Kannan
|
|
|
|
|
from what i understand the app.exe.config file is readonly. if this is true then i can't use it.
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
|
This may sound like self-advertising,
but I published something similar
that may (or may not) fit our friend's needs:
http://www.codeproject.com/csharp/CFGLitepack.asp
So, now.. if he wants to use XML, he has Nick's class;
else, he can use mine
Ain't CP great?
F.O.R.
|
|
|
|
|
Simply, I'd like to create a get property that would return a list of objects for a class, but I want that the list only allows access to items : adding, replacing or removing items must be impossible.
To do that I first wrote the following code :
class MyClass
{
private ArrayList _AL;
ICollection MyList
{
get { return _AL; }
}
}
Indeed, the ICollection doesn't have Add , Replace or Remove methods.
But I realized later that the ICollection interface returned by MyList could be cast into an IList interface on which it is possible to perform such operations, and then the list can be modified : the data can be acted an unexcepted way, and there is no integrity !
Does anyone know the answer to this architecture problem ?
Regards,
- Éric -
|
|
|
|
|
Did you try making the arraylist
readonly
Regards,
Kannan
|
|
|
|
|
Unfortunalely that's not the solution.
Indeed readonly attribute will only forbid to replace the ArrayList object AL by another instance, but one can still do anything with the list. For instance, the following code shows that an item can be added normally : it compiles and no exception is thrown.
public class MyClass
{
public readonly ArrayList AL = new ArrayList();
}
public class MainClass
{
static void Main()
{
MyClass MC = new MyClass();
try
{
MC.AL.Add("toto");
}
catch(Exception e) { MessageBox.Show(e.Message); }
foreach ( object O in MC.AL )
MessageBox.Show(O.ToString()+" has been added !");
}
}
What a pity...
- Éric -
|
|
|
|
|
|
Perfect ! That seems to be a good solution.
This static method returns a readonly copy of the ArrayList. Moreover if the original list is modified (directly or through a binding process), then the readonly copy is updated (synchronized). Very well !
Thanks very much.
- Éric -
|
|
|
|
|
|
|
Finally I'm going to use the following method :
public class MyClass
{
ArrayList _AL = new ArrayList();
public IList MyList
{
get { return ArrayList.ReadOnly(_AL); }
}
...
}
- Éric -
|
|
|
|
|
I think there's not much you can do. If you're trying to achieve the same effect as const in C++, the news is that in C++ you can just as easily cast away constness and have the same issue.
Here's my viewpoint:
You as the programmer are doing all you can to make your collection readonly. If someone wants to modify it badly enough, they'll have to take the extra step of casting it and in doing so they assume the responsibility of what problems that may cause.
In other words, it's not your problem. There's only so much you can do and spending time worrying about what some hacker may do is not worth it, IMHO.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Having said all that, I just found a ReadOnly method in ArrayList that gives you the extra safety you need.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Perfect ! That seems to be a good solution.
This static method returns a readonly copy of the ArrayList. Moreover if the original list is modified (directly or through a binding process), then the readonly copy is updated (synchronized). Very well !
Thanks very much.
|
|
|
|
|
I insert an object(object is writed as winform user control whin c#) in a webform
I want to pass some param to the object
I define the object like this
<object id="AnimTool" height="1024" width="768"
classid="/Web_1/AnimInkControl.dll#SketchBoard.Web.Animation.AnimInkControl"
="" viewastext=""> <param name="Path" />
now I want to pass the param to the object with the user selected path
because the param value is depends on the user selection
so How can I pass the Param to the object?
I used js like this
AnimTool.Path = " df"
but when I open it ,it reports js cann't found the AnimTool object
AnimTool is not define.
why,how?
|
|
|
|
|
Hi!
I have a smart phone device based on GSM/GPRS. I used the VS extension ...Smart Devices Extension to
build an application (the GUI and all) for the phone. But now I need to talk to another device which is also GPRS based.
I want a minimal functionality of passing strings from my device to the other.
How do I do this? Could you tell me where I can find information on this topic?
Zippy
|
|
|
|
|
i want to provide help in my project..how can i create help? is there any component available..?
-bhavin
|
|
|
|
|
Search for "Help Provider component" in msdn for more information.
You need to use the HelpProvider class.
To create help you can use tools like robohelp or the html help toolkit or vs help integeration kit[^]
- Kannan
|
|
|
|
|
i'm having a problem when i check some items in a listview. i have a textbox and a listview and when i check the items in the listview it updates the text in the textbox. my problem is when i check the items my event is always one step behind. example, i check 'a' and nothing happens, i check 'b' and the textbox show 'a', i check 'c' and the textbox shows 'a, b'. what event do i put my code into or is there a trick to this.
thanks,
Rob
my event:
private void lvNameDisplay_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)<br />
{<br />
System.Text.StringBuilder newText = new System.Text.StringBuilder();<br />
foreach (ListViewItem lvItem in lvNameDisplay.CheckedItems)<br />
{<br />
newText.Append(lvItem.Text + ", ");<br />
}<br />
tbExample.Text = newText.ToString();<br />
if (tbExample.Text.EndsWith(", "))<br />
{<br />
tbExample.Text = tbExample.Text.Substring(0, tbExample.Text.Length-2);<br />
}<br />
}
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
Try writing ur code in the handler for SelectedValueChanged event.
The ItemCheck event is triggered just BEFORE an item is about to be checked...and the value is updated only AFTER this event completes...that explains the "lag" u xperienced!
private void listview_SelectedValueChanged(object sender, System.EventArgs e)
{
System.Text.StringBuilder newText = new System.Text.StringBuilder();
System.Windows.Forms.CheckedListBox.CheckedItemCollection col = clv.CheckedItems;
foreach (Object obj in col)
{
//
newText.Append(obj.ToString() + ", ");
}
t1.Text = newText.ToString();
if (t1.Text.EndsWith(", "))
{
t1.Text = t1.Text.Substring(0, t1.Text.Length-2);
}
}
Zippy
|
|
|
|
|
thank you for the help but i'm using a listView not a listBox. the listView doesn't have an event for selectedvaluechanged.
thanks,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
trying to use CAPI, so I included the header on top of my WIN32 console app:
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
#include "wincrypt.h" <--- remove this, all problems are gone?
using namespace System;
// This is the entry point for this application
int _tmain(void)
{
return 0;
}
C:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\WinCrypt.h(37): error C2146: syntax error : missing ';' before identifier 'HRESULT'
The error trace to this line here:
#ifndef _HRESULT_DEFINED
#define _HRESULT_DEFINED
typedef LONG HRESULT; <-- THIS LINE
Any idea?
norm
|
|
|
|