|
YOur code has to run as an administrator. Under Vista and 7, even an admin account doesn't run as an admin account until the privilege requires it and you get the UAC box. To get around that UAC box, you have to create a manifest file in your project that specifies the app needs admin level permissions to run.
Here's[^] a quick'n'dirty on what you need to do.
|
|
|
|
|
Have u tried it to using WMI?
|
|
|
|
|
The code needs to be running as an admin regardless of how you do it.
|
|
|
|
|
Hi.
In my project have 3 module. 1 and 2 nd module writen in c++ and 3th module - Application module written in C#.
Every module different parts of projects.
My first module have like that class :
class __declspec(dllexport) MyClass1
{
public :
int n;
MySimple1()
{
n=0;
}
~MySimple1()
{
}
int Plus(int a,int b)
{
return n=(a+b);
}
};
In my second module have like that class.
And this class use 1 th class.
class __declspec(dllexport) MyClass2
{
public :
MySimple2(MyClass1 a)
{
}
~MySimple2()
{
}
...
};
Can i use MyClass1 fields (i know how to use methods) in my C# app?
In my C# app , how i can send MyClass1 like parameter to 2nd class ?
How i can use like that in my C# app ?
public MyClass1 my1=new MyClass1();
int n=my1.Plus(10,12);
MySimple2(my1);
Thanks.
We are haven't bug,just temporarily undecided problems.
|
|
|
|
|
You would need to use pinvoke and create interop to access the unmanaged classes.
This might help http://www.pinvoke.net/[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for reply.
I know how to use class methods with pinvoke. But i need use that class (NO METHOD) ?
Any ideas?
thanks.
We are haven't bug,just temporarily undecided problems.
|
|
|
|
|
I found answer here[^]
I hope that will help you
|
|
|
|
|
Runtime Call Wrapepers are for COM. This is just a normal C++ class exposed in the export table. In C++ calling methods on a class use a calling convention called ThisCall. With ThisCall the "this" pointer gets passed into the method via the ECX register and everything else is the same as STD call. .Net supports this. You can specify this calling convention in the DllImport attribute. How the constructor and destructor get called is something else. When you specify ThisCall in the DllImport attribute the first parameter of the method must be a pointer to "This". The names are going to be mangled in the export table. Use a program like dependency walker to see what they are.
Here is a good post I found on this site.
How to Marshal a C++ Class[^]
modified on Friday, October 1, 2010 2:38 PM
|
|
|
|
|
Create a wrapper class in a CLI project (C++.NET) and you should be able to access the C++ class from the .NET class. The advantage of this is that you keep your C++ project as is and you can debug both heaps easily. In this mode the unmanaged and managed heaps run within the same process without marshaling. I hope this helps.
|
|
|
|
|
Hi, I'm using an application that generates groups and assign users in active directory to manage a series of folders. i don't know much about AD and so I would like to know if someone can tell me the road. The point is that I have to manage permissions for read-only, full control ... do not know if I have to give to the groups or folders, plus I have no idea how to make it... would appreciate some help, thanks ....
|
|
|
|
|
allstarmisho wrote: I have no idea how to make it
Start by researching, then find some code-snippets and try to combine what you have. The Scripting Center[^] on MSDN has some nice examples on manipulating the AD.
Good luck
I are Troll
|
|
|
|
|
Hi,
One of the column type in my datagridview is datagridviewImage column. it has "recyclebin" image. If I'm try to edit the row, recyclebin image will be changed to edit image.
The problem is, how to know which row is having edit image and which row is having recyclebin image.
I used the below statement to compare, but its not working.
if (dgvIdentifiers["Recycle", e.RowIndex].Value == Resources.recycle)
Note:recycle is the image, resided in Resources
|
|
|
|
|
There are two ways that I have managed to do this.
1) Have a hidden DataGridViewTextBoxColumn , I call it imageHint where I store a string either the path of the image or something like, in your example, "recycle" or "edit". Then any time an image is assigned, assign the appropriate string to imageHint
2) The same principle but use the Tag property of the cell. If you are not familiar with Tag , search MSDN there are loads of examples of how to use it.
Hope this helps.
Good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I used Tag property of cell. It helped me. Thanks alot..
|
|
|
|
|
Good to know!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
Am need to overwrite the Assemblyinfo.cs file.
ex: [assembly: AssemblyVersion("1.0.0.0")]
needs to be upadted to [assembly: AssemblyVersion("4.0.0.0")]
Instead of manuallly updating i need to update it from code.
The below code reads the version number.
But i need to update it in Assmeblyinfo.cs file,can you help me to update thro code?
using system.reflection;
Version v1 = new Version("4.0.0.0");
Console.WriteLine(" New Version {0}.", v1);
Thanks,
Arul
|
|
|
|
|
Hi Arul,
Reflection does not seem to be the best way to do this. I suggest that you should search all AssemblyInfo.cs files in a specified folder (using DirectoryInfo-class). Open each file (with a StreamReader) and read the file content. Then use a regular expression (Regex-namespace) to find the "AssemblyVersion"-string and replace the version with '4.0.0.0' or whatever number you want to set. Then write the content to the file (to overwrite) by using a StreamWriter.
After that you can build your assembly with the new version number.
Let me know if you need more details on the point where you stuck.
Regards
Sebastian
|
|
|
|
|
Hi Sebastian,
Thanks for your faster response. I tried using DirectorInfo-class. But it says duplicate assembly info files.It would be great if you could chip out with code too.
Also can this be done using cmd prompt.?
Thanks,
Arul
|
|
|
|
|
If you download my MoXAML PowerToys addin source code (follow the link in my sig), you will find plenty of code in there for reading and navigating VS projects - once you've got that in place, it's a simple case of just opening and reading the appropriate file - then looking for the relevant line of code.
|
|
|
|
|
Here's mine[^], there are others.
|
|
|
|
|
I am using a composition of some different code samples to try to work with a WPF (MVVM) application. I started with Josh Smith's multiple view workspace model as below (pertinent snippet)
#region workspaces
public ObservableCollection<WorkspaceViewModel> Workspaces
{
get
{
if (_workspaces == null)
{
_workspaces = new ObservableCollection<WorkspaceViewModel>();
_workspaces.CollectionChanged += OnWorkspacesChanged;
}
return _workspaces;
}
}
private void OnWorkspacesChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null && e.NewItems.Count != 0)
foreach (WorkspaceViewModel workspace in e.NewItems)
workspace.RequestClose += OnWorkspaceRequestClose;
if (e.OldItems != null && e.OldItems.Count != 0)
foreach (WorkspaceViewModel workspace in e.OldItems)
workspace.RequestClose -= OnWorkspaceRequestClose;
}
private void OnWorkspaceRequestClose(Object sender, EventArgs e)
{
var workspace = sender as WorkspaceViewModel;
if (workspace != null)
{
workspace.Dispose();
Workspaces.Remove(workspace);
}
}
#endregion
#region private helpers
private void DisplayAllFoo()
{
var workspace =
Workspaces.FirstOrDefault(vm => vm is AllFooViewModel)
as AllFooViewModel;
if (workspace == null)
{
workspace = new AllFooViewModel();
Workspaces.Add(workspace);
}
SetActiveWorkspace(workspace);
}
private static void DisplayFoo()
{
}
public void SetActiveWorkspace(WorkspaceViewModel workspace)
{
Debug.Assert(Workspaces.Contains(workspace));
var collectionView = CollectionViewSource.GetDefaultView(Workspaces);
if (collectionView != null)
collectionView.MoveCurrentTo(workspace);
}
#endregion
So it is easy enough to work with that, XAML code produces a list of commands which point to the voids above. I wanted to use a treeview navigation structure so I could categorize my navigation commands into categories. I used Josh Smith's (PS Thanks Josh Smith!) WPF MVVM Treeview to make a viewmodel for my categories and navigation items and everything is good there. My issue is this, the navigation commands for each navigation item are on the NavigationCommand viewModel, while the workspace and setactive workspace commands are on the mainWindowViewModel. How do I make this work? How can I call the SetActiveWorkSpace command from my NavCommand viewModel?
Sorry for the mess, --EA
P.S. I do lack a lot of fundamental understanding of WPF, just trying to get a foothold in it.
|
|
|
|
|
I don't know whether I get your requirement correctly but try this,
Create a static instance in the MainWindowViewModel and use MainWindowViewModel.Instance.MethodName() for accessing the method.
|
|
|
|
|
A common way to do this is to use something like a mediator (or the Messenger class in Laurent Bugnion's excellent MVVMLight framework). Basically you register a listener for each command in the MainWindowViewModel and then raise the appropriate command in the NavigationCommand VM - the listener will then react to it.
|
|
|
|
|
I think my fundamental problem is that I am not sure how to work with one viewmodel from another. Here is the breakdown.
Mainwindow has a data context of Main Window View Model. The command to add and set active workspace resides on this view model.
On the mainwindow there is a custom user control treeview that has a data context of navigationcategory view model. Within the treeview each bottom level node is a hyperlink. The binding for each command for each hyperlink is bound to the navigationcommand view model.
With that said, the command on the navigation control view model needs to do something to add a new workspace and change the active work space on the main window view model.
So the question is, what does the command look like on the navigation command view model to tell the main window view model to add a new workspace (based on whatever item is chosen on the treeview)
|
|
|
|
|
Solving this is easy if you have a workspace manager class (which would be a static instance) - then you simply call a method on this manager class to add a window to the workspace that belongs to the appropriate type.
|
|
|
|