Click here to Skip to main content
12,506,280 members (56,026 online)

Comments by Grasshopper.iics (Top 12 by date)

Grasshopper.iics 22-Jan-13 11:27am View
If you are using Digital Persona, then it comes with a driver. Every driver puts a registry entry. There are some simple Win API method which can detect when a USB device is inserted. You can compare the device ID and use some password to activate the device.

However if a hardware lock is so important, cant there be a USB hub? Logic remains same. Alongside the device you provide a USB stick and embed it's ID into program for password checking. However if such a solution needs to be distributed in lot then software lock might be best option?
Grasshopper.iics 21-Jan-13 20:47pm View
You have set SeriesChartType.Point, it should be SeriesChartType.Column
Grasshopper.iics 21-Jan-13 18:53pm View
BeginInvoke by UI controls or thread is meant to be executed at the background. So When you have loads of statement and use BeginInvoke at the end, UI gets updated smoothly. Do a simple test. Take a Label, and a button. on click event write the following code.

for (int i = 0; i < 100; i++)
label1.Text = i.ToString();

// your UI update code here. e.g. this.Close();Label1.Text="something";
// System.Threading.Thread.Sleep(2000);

Dont you see your UI in wait state? That is what I mean. In his code context, calling BeginInvoke from inside nested loops is not executing asynchronously. First Invoke is locking the resource, the second call is waiting for that to complete. So even though they are executing asynchronously, lock is not managed that way.
Grasshopper.iics 21-Jan-13 18:33pm View
Put argument to rest, please check with the suggested changes first!
Grasshopper.iics 21-Jan-13 3:17am View
I am sorry, but I really don't get you here SA. I considered member to be relatively new in coding as he seems to be relatively new to cp. So I offered an easy way out. You voted me 1, stamping the answer not suitable. I pulled out some work from another project which I found some times back in stackoverflow. This solution works best, no matter what your file type is.

But you are now saying that the solution is complicated. By the mean time OP has not come back to comment on any solutions or clarifying any point.

Should we consider
1. To check if a file is locked, my first solution
2. To find the exact process and the name with file handle, my second method.

Where I used it?

I have controlled power point slide through some stuff like lasser , voice, hand movement, eye blink. I use this technique to find out the Handle (Int32 pointer to process) and then I pass the keys through Sendkey(). So please clarify if I am wrong in my either cases.
Grasshopper.iics 21-Jan-13 1:54am View
This works fine under Windows 7, does not require to open another process ( handle.exe). All you be doing is using GetProcessesLockingFile() method. Solution to Non trivial problems can not be trivial. Even handle.exe shoots up loads of problems !
Grasshopper.iics 21-Jan-13 1:33am View
As par your question, it was meant to be "if a file is being used by another process". Do let me understand if your question suggest anything in particular which is not answered? Say if you needed an information about "which process is currently accessing a file?"

If you had, I would have given you following solution which will display the process that is actually holding your file access ( Somethimes back I had done similar stuff, ref

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Text;
using System.Threading;

namespace FileLockInfo
public class Win32Processes

static void Main()
Console.WriteLine("C:\\Users\\Rupam\\Desktop\\Transaction Details.pdf");

GetProcessesLockingFile("C:\\Users\\Rupam\\Desktop\\Transaction Details - PayPal.pdf");

public static List<Process> GetProcessesLockingFile(string filePath)
var procs = new List<Process>();

var processListSnapshot = Process.GetProcesses();
foreach (var process in processListSnapshot)
Console.WriteLine( process.ProcessName);
if (process.Id <= 4) { continue; } // system processes
var files = GetFilesLockedBy(process);
if (files.Contains(filePath))

return procs;

public static List
Grasshopper.iics 23-Sep-12 5:00am View
You would fail to get solution. You will try. You will not get there. You keep on trying. So you are glued to your system till you get the solution. Once you get there, you will be more confident and will try to see the end of any programming problem the same way. Keep working is the motto! 18 hours is a phrase. Dont we all intrinsically agree to it?
Grasshopper.iics 18-Jan-12 0:08am View
This is already suggested in Alternative 1.
Grasshopper.iics 18-Jan-12 0:07am View
Hi! Thanks for this. This is really something I missed out. :)
Grasshopper.iics 14-Jan-12 0:32am View
I have accepted your alternative. But the essence of the topic is "Simple Conversion". Using pointers with unsafe is more efficient than color matrix. But the mentioned code here ( in main tip) is much simpler and the same loop can be used to produce binary image, edge detection, any other transform. :)

Also the gray scale value can be obtained just by taking the average of R,G,B and replace it in all three channels.
Grasshopper.iics 9-Jan-12 12:51pm View
Reason for my vote of 5
Great Work!

Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid