|
Thanks for all the help dude;P
i've figured out just another way to solve the problem.
Until Next time
Regards
|
|
|
|
|
can u also guide me about a way to set focus of the mouse on the column and all its cells, whose header is clicked.
|
|
|
|
|
Once you know what the column is, through the method I told you, if there's an API to select a column, you can call it.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
I wanted to know if i could get a sample code in C# for SetWinEventHook.. This I want to use to track the events(Mouse and KeyBoard) in a .NET Application..
After that, Is there a way, that i can use this API(SetWinEventHook) like SetWindowsHookEx to inject code into the target Application's Address space and get the Control information on which the Mouse is Clicked?
Regards
Pattu
|
|
|
|
|
www.pinvoke.net[^] is the place to go if you want to call Win32 APIs in C#.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi Graus,
I actually looked at www.pinvoke.net.. But I wanted a Sample code to use this API...
It would be great if i can get it..
Regards
Pattabhi
|
|
|
|
|
Google for it. The point of pinvoke is that you're calling a Win32 API, so the Win32 docs is the place to look for help on how to call it
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
private void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild,
uint dwEventThread, uint dwmsEventTime)
|
|
|
|
|
Hello gurus,
As the subject says, I'd like to know how I can detect if a service is running in C#?
Is there an equivalent of the vb script IsServiceRunning function in C#???
Can someone provide me a code snipet please?
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
Hi,
ServiceController.Status give the status of the service. I guess you can use this.
Thanks and Regards
Mahe
|
|
|
|
|
using system.serviceprocess
// u have to add a dll file
System.ServiceProcess.ServiceController svcCtrl = new ServiceController("your service name ");
string mystatus=svcCtrl.status.ToString();
Console.Writeline(mystatus);
|
|
|
|
|
Hi,
It works fine now
Thanks a lot!
Best regards.
There is no spoon.
|
|
|
|
|
Hi
I would like to generate the text file with the help of Template Programming using C#. Please explain me how .Net 2003 supports and what are all the options in framework to create such kind of programming.
Please provide me a example also.
Thanks.
|
|
|
|
|
Templates are called generics in C#. I can't see any reason why you'd need templates to create a text file. Generics do not exist in .NET 2003.
The System.IO namespace contains all the classes you need to interact with the file system. This[^] is a good resource on the subject.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I have tested this significantly and it gets curious-er. I installed a drive that has nothing but MP3 files on it. I went in a command com and issued a “Dir *.mp3 /b /s > test.txt” to create a list of all the files on the drive. I read the file with a text editor and there are 17,247 files listed. Okay I run the program I have been testing and it finds only 16800 files. Here is the code I used to which I introduced a counter with which I report to a message box in order to confirm the exact number in the array. The number in the array agrees with countFiles.
void DirSearch(string sDir)
{
try
{
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, "*.mp3"))
{
arrText.Add(f);
countFiles++;
}
DirSearch(d);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
}
Upon examintion of the array in the list box there is also 16,800 files in the list box but I notice that I have a directory for “World” music which is not present in the list. Out of curiosity I change the name of the directory from “World” to “aWorld” and run the program without any other changes. The program reports 17,005 files which reflects the approximate number of files in the “World” directory.
It seems that there is something strange happening in DirSearch that is beyond my feeble mind. Since it will not read anything alphabeticaly beyond “Rock and Roll” could there be some kind of musical prejudice at work? That’s a joke.
|
|
|
|
|
>dir also lists the directory names themselves, whereas your code does not count them.
Luc Pattyn
|
|
|
|
|
This would not account for the difference of 200 files when "world" is renamed to "sworld". I do understand what you are saying and will set up a more precise test when I get rid of the major bugs. There is only 15 directories on the root of my test drive with no more that 15 or so sub directories.
Tnx for the suggestion
|
|
|
|
|
if I just do a "DIR *.* /s" this should yield a correct count of the files on a drive shouldn't it?
|
|
|
|
|
dir /s promises to list files
and GetFiles() returns a list of files
In .NET file seems to mean leaf node in the file system's hierarchy;
in DOS I dont know, maybe they still realized a directory was actually also a logical unit
of information, aka file.
My observations indicate a difference between both worlds, I guess that is what
progress is all about ?
Luc Pattyn
|
|
|
|
|
No files are in the root directory ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
None unless they are hidden system files.
|
|
|
|
|
Well, perhaps they are.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
WE have differences of many hundreds of files. I have now verified that all directories with names more than alpha 't' are not being read. For example the directory "world" is not read change name to "sworld" and it is included. Change the name to "tworld" and it is not.
|
|
|
|
|
I suggest you adapt your code to produce a file similar to the one from the DOS command.
Then a simple WinDiff should point you straight at the heart of the problem.
Luc Pattyn
|
|
|
|
|
I have revised my program to examine all the files on the C: drive. I have placed the files in a sorted list box.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
static int countFiles = 0;
public Form1()
{
InitializeComponent();
}
ArrayList list = new ArrayList();
void DirSearch(string sDir)
{
try
{
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, "*.*"))
{
list.Add(f);
countFiles++;
}
DirSearch(d);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
listBox1.Items.Clear();
listBox1.Sorted = true;
list.Clear();
countFiles = 0;
DirSearch("c:\\");
foreach (string s in list) listBox1.Items.Add(s);
listBox1.Items.Add(" --> Number Of Files = " + countFiles);
this.Cursor = Cursors.Default;
}
}
}
When I run this code all directories begining with the letter 't' or more are NOT present this includes the "Windows" directory. I have now tested this on four different machines all of which report the same erroneus result. A directory called "system" is found and one called "text" is not.
|
|
|
|