|
Is is possible to take ownership of a file using c#. (Like when you right click on a file in explorer, click properties, securities, and then the take ownership button).
Anybody have any c# examples on how to do it and what namespace should you use.
Cheers in advance
Satvinder
|
|
|
|
|
OK , I managed to get a answer but the example is in VB6.
The article for all who want to know is a MSKB article 318744, which I will try to convert to C#.
http://support.microsoft.com/default.aspx?scid=kb;en-us;318744
|
|
|
|
|
I am new to C# and am trying to call some old legacy C stuff that accepts as input a pointer to a struct that has several fields that are pointers to large byte arrays. I am able to get a clean build but am not able to run without getting an exception that says something like unable to marshal structure field of this type (it's referring to the array pointer (reference) fields). I have even tried unsafe mode but have had problems taking the address of an array. I am using the Beta-2 Visual Studio. tfbriscoe@msn.com
Tom
|
|
|
|
|
tfbriscoe wrote:
I am using the Beta-2 Visual Studio
Well, not sure of the exact changes in the Marshal class, however why don't you post a little code so everyone can take a look at what you are doing.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Hi Nick. Thanks for your willingness to help! I solved the problem yesterday in both managed and unsafe modes. Just had to do a little more research about unsafe mode, "fixed" code groups, and structure layout attributes!
|
|
|
|
|
I'm working on a desktop toolbar type application, much like a suped-up
taskbar. I would like to take advantage of the dockable feature to dock the
bar with the desktop, is this possible or will I have to do it manually.
Another feature I would like to implement is the ability for the bar to
slide in and out of view, much like the tasbars ability to auto-hide. My
initial thought for this sliding functionality was to move the bar's x-y
position off the screen using a SetDesktopLocation(...) loop, finishing at
the bar's width. However, a form at (0, 0), of width 70 pixels docked on the
left side of the desktop shifted to (-70, 0) does not shift off the desktop
completely, I need to shift to about (-120, 0) for the form to disappear. Am
I using the correct function, or even the correct idea?
Thanks in advance,
-e
|
|
|
|
|
Rather than shifting the position of the toolbar, you may try resizing it to a width of 0 pixels. This should result in the desired effect.
You could perform this action with some pizzaz by animating the resizing of the control. If you're interested, check out ActiveWare Solution's AWControlAnimator at http://www.ActiveWareSolutions.com
-msf
|
|
|
|
|
Anonymous wrote:
Another feature I would like to implement is the ability for the bar to
slide in and out of view
I have actually been working on something like this for a while, however with classes a lot of my "projects" go into a hibernation mode. I found something like the following works well. The reson I resized to a width of 2 was that allowed for a white line to be drawn and shown along the edge of the form similar to the edge on your task bar when you look really close.
void HideMe()
{
while(this.Width > 2)
{
this.Width -= 1;
Thread.Sleep(10);
this.Refresh();
}
}
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Nick Parker wrote:
however with classes a lot of my "projects" go into a hibernation mode.
Too bad. Your presence is a good value to us all.
|
|
|
|
|
.S.Rod. wrote:
Too bad. Your presence is a good value to us all.
<Hoping your not being sarcastic>
I'll still be around, editing articles and bugging you about that LoadLibrary() API...
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Nick Parker wrote:
bugging you about that LoadLibrary()
This is hardcore.
|
|
|
|
|
.S.Rod. wrote:
This is hardcore.
Hey, I gotta keep you busy and on your toes.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
I should have been using the Form.Location property instead of SetDesktopLocation(...), I now have a nice sliding motion but: When hiding the bar with a sliding motion the animation stutters as the window under the receding bar is being redrawn. This does not happen when the taskbar hides itself. Any ideas on preventing this?
Also, when the bar is hidden, moving the mouse to the edge of the desktop should trigger the bar to be shown. Can an event be triggered when this happens or even on any mouse move. The Form.MouseMove event won't work as this only occurs when the mouse moves over the control, but the control will be hidden.
Thanks again,
-e
|
|
|
|
|
on any of your animation you might want to setstyle for double buffering and all draw in wmpaint ..i was writing some fading panels a while back (XP Style Menus) and once controls get added to it you'll need the double buffer..my control slides up and down and fades in and out, and i ended up having to double buffer to prevent flicker..
|
|
|
|
|
I enabled double buffering using:
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
but it makes no difference, the form still slides slowly when redrawing the window underneath.
Thanks,
-e
|
|
|
|
|
I presume double-buffering doesn't work as this only applies to drawing within the form, but its the redrawing of other windows that's slowing down the motion.
|
|
|
|
|
I give in, after two days of trying to resolve a problem i need your guys help. First i have a microsoft complaint.
Why does microsoft give hundreds and hundreds of (the same) example of how to move through a bound DataTable one by one,
ie. this.BindingContext[dsPubs1, "authors"].Position += 1;
but not for my scenario below.
My Question:
I have a customer details form with numerous textboxes all bound to the same datatable. Now if a user enters an Account Number i go and retrieve the related rows information. How do i get the textBoxes to reflect this change in row.
I'm sorry i cannot give you an idea of how i have tried to get round the problem as i have tried alot of ways, with no luck. The textBoxes are bound at runtime.
Any help would save me going bold.
Thanks
Matt G
|
|
|
|
|
How do you mean? Let's say you have a DataTable that, conceptually, looks like this:
ID |Employee
-------------------------------
0 |Fred
1 |Jack
2 |Jane
3 |Bill
Now, you have a textbox for a user to input an ID, and then a submit button. Now, when they click submit, you retrieve the data from the DataTable object and then display it in another textbox right? Is that kind of how it's going? Also, which type of object are you using to hold the data? A DataSet, XxxDataReader, what?
Hey, what can I say? I'm a chick magnet...a babe conductor...a logarithm for the ladies.
-Strong Bad from HomeStarRunner.com
Essential Tips for Web Developers
|
|
|
|
|
Thanks for your responce David.
Yes this is what i am trying to achieve. I have managed to sort it out, its abit more hassle getting used to no cursors, than i thought it would.
I passed the whole DataTable to a DataView, where from i could use the find command to return the DataRow position, and set this to the DataBinding Position property. Its easy when you know how - hey!
PS. Is there a better way?
Thanks
Matt G
|
|
|
|
|
|
Hi All,
Any insight into the following would be greatly appreciated. Onto the problem...
Here's the quick version of what I'm looking to answer:
- What is the order in which the services are stopped?
- Is there a differentiation between system services and user/application services?
- If so, are system services treated differently than user/application services?
- Is there a way that we can control the shutdown process enough to enable our service to terminate as it was intended?
- Is there any Microsoft documentation availible that addresses Windows services and system shutdown?
Here's the background
The application in question is being written in C#, and implemented as a Windows service. When the service reads data from the mainframe (MACS), it has no option but to do so destructively. Once the data is read into memory, it no longer exists elsewhere until the service massages the data and deposits it into SQL Server 2000. There is no known way to read the data in a non-destructive manner, nor to "peek" at the data without performing the destructive read... this is an area that we're also pursuing.
The service consists of two threads. The main thread exists only to listen for, and respond to, Service Control Manager (SCM) requests. When the SCM requests a Start, the main thread creates a worker thread (priority:normal) to perform the needed tasks. The worker thread performs these tasks using an object that both it and the main thread hold a reference to. When the SCM requests a Stop, the service signals the worker thread by calling a thread-safe method on the object. The main thread joins the worker thread, in order to remain alive until completion. The worker thread will terminate when all of the data in memory has been safely written to SQL Server, and the external connections have been closed.
Here's the problem
The problem that we're having with the service implementation is related to the computer being shutdown or restarted. The service has programmatically requested to receive notification of the system shutdown event (by setting System.ServiceProcess.ServiceBase.CanShutdown property to true). When the service is notified of the shutdown request (through the OnShutdown()method), the main thread signals the worker by calling a thread-safe method on the shared object. The main thread joins the worker thread, in order to remain alive until completion. The worker thread terminates when all of the data in memory has been safely written to SQL server.... or at least that is the intention.
In reality, it seems that the OnShutdown() method is being called inconsistently, or is not being given ample time to execute. When called, the worker thread is unable to write to SQL server, the file system, or the event log before the system finishes shutting down. It appears that the system services that enable data, file system, and event log access are terminating before our service. As a result, our service is not consistently able to preserve the data currently in memory. There are times when everything works properly, there are other times when we're only able to perform some of the needed actions, and there are still other times where it doesn't appear that the OnShutdown() method is being executed at all. I'd venture to guess that the services are terminating in a random order, and in most cases, the system services that we rely on are shutting down before we are finished with them.
One of the biggest difficulties is that we're, for the most part, unable to determine exactly what is happening. If we try to attach a debugger to the process, it is usually terminated (due to the system shutting down)... we can't consistently write to the Event Log, to SQL Server, nor can we consistently create a text file, to log the actions being taken. On the lucky trials, we may be able to produce an event log entry or text file indicating that we've entered the OnShutdown() method. Beyond that, unless the write to SQL Server is successful, we aren't able to do anything. Even a second call to the Event Log's WriteEntry() method, placed immediately after the first (successful) call, does not appear to run.
--Jesse
|
|
|
|
|
AFAIK, you should register you service as depending on the SQL Server service, so the OS can properly determine the startup sequence. Actually, you should register any of your service's dependencies. Probably, this information is needed for the right shutdown sequence too (my conclusion here). On .NET, you have the ServicesDependedOn property on the ServiceInstaller. Another remark: by default, if your shutdown process takes more than 20s, Windows will presume your service is hung up and probably will kill your process. There's a registry entry for configuring this time.
[edit]Debugging tip: Use Trace.Writeline or a interop call to OutputDebugString and use dbgview or dbmon to see it.[/edit]
I see dumb people
|
|
|
|
|
I am creating a simple tabbed text editor using the Magic .NET UI bits [http://www.dotnetmagic.com[^]]. My question is how do I programmaticly manipulate opjects that are on the tabs I create?
In a non-tabbed form I would use:
<br />
richTextBox1.Cut(); <br />
richTextBox1.Copy(); <br />
but I cannot figure out how I can get to the textbox inside a tabControl page. Im sure that this is probably simple, but I cant find it. Any help would be greatly appreciated.
I looked at the documentation here: http://www.dotnetmagic.com/articles.html[^]but I couldnt make any sense out of it.
You can find the test project I'm experimenting with here:
http://www.exceed-tech.com/misc/TabTest1.zip [^]
|
|
|
|
|
tabPage.Controls[0].Cut() , assuming your richTextBox1 is the first control on your tab. If you need to find a specific one, just enumerate through the controls in your TabPage.Controls collection and find the Control with the right name or type. This is behavior that all System.Windows.Forms.Control (and System.Web.UI.Control for that matter) exhibit.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Thanks Heath,
Is there an easy way to check for the active control index?
DB
|
|
|
|
|