|
If the file is opened DenyShareRead by the host process, you can't open it until the host closes the file, period. There's no way around this.
By deault, the FileStream object opens a file with FileShare.Read permissions. That means that any other process can open the file for reading while you have the file open.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How can I ensure that only one copy of my application (C#) runs?
(In technical terms - it may mean one process or one thread or something else?)
Thanks
|
|
|
|
|
Don't you like to search here before ?
You can use mutex for it. There are a lot articles on the topic. Here is one of them [^].
Andrew
|
|
|
|
|
hi
do this
public static void Main()<br />
{<br />
<br />
System.Diagnostics.Process[] process = <br />
System.Diagnostics.Process.GetProcessesByName("YourAppName");<br />
<br />
if ( process.Length >= 2 )<br />
{<br />
MessageBox.Show("Application already running..");<br />
Appliction.End();<br />
}<br />
else<br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
}
Mihir...
|
|
|
|
|
Hi,
How to check the version of MSWord installed in the pc in C# ?
Any code samples ?
Thanks
|
|
|
|
|
I have a Win32 DLL that has a standard _stdcall (WINAPI) exports. I am able to call these fine from C#. One call in particular however has a callback to a CDECL function. How would I set that up? Following is the specific.
Win32 DLL Declaration for function in MyDLL.dll
extern "C" int WINAPI SpecialTimerFunction(int Val, int (*Callback)(int InVal))
C# Declaration
public class MyClass
{
public delegate int MyCallback(int InVal);
[DllImport("MyDLL.dll")]
public static extern int SpecialTimerFunction(int Val,MyCallback Callback);
}
How do I declare the delegate to ensure that the marshaller will understand that the callback is of type CDECL?
Thanks a million.
Berto
WCSC (Willies Computer Software Co)
http://www.wcscnet.com
|
|
|
|
|
Think RS232 wrote:
public delegate int MyCallback(int InVal);
This looks correct.
Define the import function as:
static extern int SpecialTimerFunction(int Val,IntPtr Callback);
When you are creating the delegate wrap it in a GCHandle (pinned). As follows:
GCHandle gch = new GCHandle(new MyCallback(foo), GCHandleType.Pinned);
int res = SpecialTimerFunction(bar, gch.AddressOfPinnedObject());
gch.Free();
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
|
|
Hello,
I'm trying to implement multiple sort in a ListView control (yes, it will come later to CP as an article) but I can't find out if the Ctrl key is pressed down when I get the ColumnClick event.
In Win32 there's GetKeyState , but what's the equivalent in .NET? Any ideas?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
For Ctrl, Alt and/or Shift, you can check the Control.ModifierKeys[^] property.
Otherwise I think you're stuck with P/Invoke on GetKeyState .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks, that will do it!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
If i add to my application a splitter and i try to move, it shows a transparent line following the cursor.
I would simulate this line.
I've to show this line if i click on a panel.
How could i do?
|
|
|
|
|
|
i don't need about it, sorry but i need only to show a semi-transparent line the follows the cursor when i click and move the panel (used as splitter).
Please any suggest?
|
|
|
|
|
Oh .. sorry misunderstood your qstn. Though I don't have much experience in System.Graphics, you'll have to manually implement the drawing with brush/lines.
|
|
|
|
|
I have a problem.. a strange problem.. a have an application with a picture box.. when i build it everithing is perfect.. so i build it, and i make a copy of the program, and move it to some other folder.. when i run my application, the picture looks really bad.. can anyone help? pls..
|
|
|
|
|
What dou you mean by looking really bad?.
|
|
|
|
|
I mean that other colors appear instead of the ones that were supost to.. and the contours are smudged... the really strange thing is, that if i keep the debug folder opened the picture displays correctlky (it's a picture on a form that loads on startup
|
|
|
|
|
I think you specified the value of the picturebox image at design time. Instead of that, load and set your image at run time. this will retain the quality.
- Malhar
|
|
|
|
|
OK Now, supose i don't want anybody to be able to mofify my picture, what should i do? Hope i'm not bugging you too much
|
|
|
|
|
Rename .jpg to .dll ..!!!! Just kidding!!
You can embed the image as a project resource by making image part of the project and extract the image just as you were accessing file.
System.Reflection.Assembly asm = GetType().Assembly;
StreamReader stream = new StreamReader(asm.GetManifestResourceStream("FULLY_QUALIFIED_NAMESPACE.FileName.jpg"));
|
|
|
|
|
Thank you very much . Hope I'll get it right( )) )
|
|
|
|
|
i still can't make that picturebox look good... i managed to embed it, and now i set it's value at run-time.. pls help
|
|
|
|
|
Huh .. strange .. is it a very large or a high-DPI picture? I can certainly give it a try if you dont mind uploading the image.
|
|
|
|