|
Hi,
I have created a domain user through code using ActiveDs. I want to add that user to administrative group using c#.
i have to do the same in workgroup environment also
Please help me to solve this problem
Thanks in advance
Regards
Subin
|
|
|
|
|
I have tried passing variables (strings) by reference to a new, daughter form where the values will be manipulated. This works and the new values are clearly seen on the parent form during debuging. BUT, when the daughter form is closed the modified values are lost and the parent form has only the origional values.... can this be correct? Is this by design (an 'undocumented feature') or have I missed something important here?
Peter Beedell
"Remember that age and treachery will always triumph over youth and ability." Quoted from the BBC Comedy 'The Office'.
|
|
|
|
|
This is all be designed, and well-documented if you read the .NET Framework SDK. While a String is a reference type (and, hence, always passed by reference - at least in C#), it is immutable; any changes you make to the string are actually made on a copy. Why do you think that methods like String.Replace return a string?
If you want to modify a string from a method in a child class, either return a string from your method or default an out or ref parameter like so:
using System;
class Test
{
static void Main()
{
string value = "Hello, world!";
Console.WriteLine(value);
value.Replace("Hello", "Guten tag");
Console.WriteLine(value);
Change(ref value);
Console.WriteLine(value);
}
static void Change(ref string value)
{
value = "Tschuss!";
}
} For value types - numbers, enumerations, and structures - they are always passed by value, so you have declare value type parameters using out or ref if you plan on changing their values.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Stewart, thanks for responding only I think you have missed my point.
Passing my string variables by reference to methods on a daughter form (modal dialog) indeed seems to work. Changes to the referenced object are seen on the parent form as if they are one and the same - which is exactly what I expected and wanted. What I do not understand and what is causing me a problem, is that when the daughter form is closed, the referenced objects resort back to their origional values.
Even if this is as described in the SDK, it seems to me to be rather un-helpfull and illogical.
Peter Beedell
"Remember that age and treachery will always triumph over youth and ability." Quoted from the BBC Comedy 'The Office'.
|
|
|
|
|
What referenced objects? The string you're passing to your modal dialog from your parent form? Some code snippets would be helpful, since what I said about strings in my previous post is true. When you assign a string you change the reference to another string object or literal. Unless that string is passed by ref or out it wouldn't change in the parent form. So, again, some code snippets would be helpful.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Dear all,
im a c and c++ programer now im jumping in the C# world. im creating a screen saver from c# how can i create a full scrren plaes help with short code.
thank you
biran
Biran
|
|
|
|
|
If you search[^] for "screensaver" in the search box just below the logo on every page on this site, you'll finds lots of examples and articles about creating screensavers in C# (and in .NET, in general).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Dear Microsoft,
thank you for the reply, actualy i am writing same like screen saver but not screen saver. My question is this how to create full scrren window? in c#,
i am not using wizard i am writing by empty project and code base.
please help again.
thank you
biran
Biran
|
|
|
|
|
biran wrote:
Dear Microsoft
No, my name is Heath. As my sig implies I do not speak for Microsoft unless I'm explicitly saying I do. I do this of my own free will and on my own time as I have for the past few years here on CodeProject.
If you look at some of those articles, it explains exactly what you have to do to your Form :
using System;
using System.Drawing;
using System.Windows.Forms;
class Test : Form
{
static void Main()
{
Application.Run(new Test());
}
Test()
{
FormBorderStyle = FormBorderStyle.None;
Bounds = Screen.FromControl(this).Bounds;
Button btn = new Button();
Controls.Add(btn);
btn.Location = new Point(8, 8);
btn.Text = "Close";
btn.Click += new EventHandler(Close);
}
private void Close(object sender, EventArgs e)
{
Close();
}
}
You set FormBorderStyle to FormBorderStyle.None and set the size and location (bounds) of the form to that of the entire screen.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi, I need a suggestion on securing a database. I have a table which has new values inserted by importing a csv file. These rows are then marked as used, when a client uses a voucher number associated with that row. I have a hash value for each row which ensures that a user cannot just reset its used status.
However, I realise that a user could very easily just delete that row and reimport it. I know this cannot be stopped, but I just need some suggestions on how I could ensure they are not doing this. DB level security will not work, as each computer which will use this app is standalone, and the owner of the computer will have all rights to the db through the SA login. Can I block the database owner from modifying the table?
|
|
|
|
|
Either parse the input and block on any violations according to your requirements, or realize that if the user has SA privileges there's nothing you can do anyway.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
|
Hi, I am interested in your idea, but not to sure what you mean. Would the trigger be used to prevent an update?
|
|
|
|
|
|
I have multiple printer drivers installed (e.g. EPSON, RICOH, CANNON) on my computer. Is there any way to check/get the PrinterSettings of any of them using Printer Name? i.e. if I want to check EPSON printers PrinterSettings that may not be the default printer, how to do it?
Please guide
|
|
|
|
|
Use the static PrinterSettings.InstalledPrinters collection property to get a collection of the printer names. You can enumerate this collection, or if you know the name of the printer, you can set PrinterSettings.PrinterName , like in the following example:
PrinterSettings printer = null;
foreach (string name in PrinterSettings.InstalledProperties)
{
printer.PrinterName = name;
if (printer.IsValid)
{
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
thanks for the reply.
continuing the same topic;
How to set any one of Printers as Default Printer?
regards
|
|
|
|
|
The easiest way is through WMI. While on NT-based platforms you can make a single function call (you have to P/Invoke SetDefaultPrinter ), the steps for Windows (i.e., Win98 and ME) platforms are more numerous.
WMI exposes a Win32_Printer.SetDefaultPrinter method that abstracts the correct implementation:
using System;
using System.Management;
class Printers
{
static void Main(string[] args)
{
EnumeratePrinters(args.Length > 0 ? args[0] : null);
}
static void EnumeratePrinters(string defaultName)
{
ManagementObject defaultPrinter = null;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
"select * from Win32_Printer");
foreach (ManagementObject printer in searcher.Get())
{
string name = printer["Name"].ToString();
Console.WriteLine("Printer: " + name);
if (defaultName != null &&
string.Compare(name, defaultName, true) == 0)
defaultPrinter = printer;
}
if (defaultPrinter != null)
{
Console.WriteLine("Setting default printer to \"{0}\"",
defaultPrinter["Name"]);
defaultPrinter.InvokeMethod("SetDefaultPrinter", null);
}
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi~
I am writting a program to get the email using MAPI by P/Invoke.
Except inbox, Can I get the emails item from other folder such as outbox?
Thanks
|
|
|
|
|
hi,
how to preprocess "ctrl + c" in console program,i want to using .net class implement this function.
thanks
|
|
|
|
|
Each time I try to create an ASP.NET Web Application I get the "Web Access Failed" dialog box...IIS is installed and running correctly, however I keep getting the following error message:
<br />
The default Web access mode for this project is set to file share, but the project folder at 'http://localhost/WebApplication1' cannot be opened with the path 'c:\Inetpub\wwwroot\WebApplication1'.
Can anybody explain why i keep getting this? IIS is running correctly and so are the rest of my Visual Studio .NET applications...I only get this when I try to create Web Applications...
Thanks
|
|
|
|
|
This may happen if you are not exceuting your application in Administartor or same privilaged environment. Try to execute your web application in Administrator mode. If it is not serving your purpose try to post in Asp.net thread.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Hi all,
I got this C++ dll that comes with a input/output card, How do I import and start using this in C# . Do point to any useful reference . Thank You
|
|
|
|
|
Consuming unmanaged components and .dlls are very easy in .Net Framework. Please go through Interop and P/Invoke technologies of .NET.
P/Invoke and Interop
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Thank you very much. Very useful link
|
|
|
|