|
See how good CP is? Almost so good, it can help yourself
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I have a question about how to hook API with the C# onely.
We know we can use vc++ to create DLL .
if we want to hook API ,we must use the ASM in our code.
We can use ASM in vc++.So we can hook API.
but how can we use ASM in C#?
|
|
|
|
|
If your talking about Windows hooks there is a good article at
http://msdn.microsoft.com/msdnmag/issues/02/10/CuttingEdge/default.aspx
|
|
|
|
|
Does anyone know where to download Windows XP common icons, such as cut, copy, delete, etc.
Microsoft stated in the Window XP Design Guidelines that they would provide them in the future, that was 2001.
I have already tried using a icon extracter, however the common icons aren't stored as resource icons.
|
|
|
|
|
I just did a qick search of the www and found "http://www.xp-icons.com/". I do not know if this help you. I used google: "Windows XP icons". Of cource you already tried that, blast it. Microsoft is a confussing critter, at times they try to give you what you need (some what ofuscated), while at other times they seem to try and hide it.
INTP
|
|
|
|
|
Because most of these "icons" aren't really icons; they are contained within a bitmap resource that is used in a masked image list. If you open shell32.doo or shdocvw.dll, you'll see several bitmap resources of various sizes and resolutions. You can either keep these as a bitmap and specify the size of a single image and the transparency color in your ImageList , then use ImageList.Images.AddStrip which will create individual images from the bitmap resource. You can also do this yourself by opening the bitmap in a decent image editor, splitting the images, and masking the color yourself (or still use the transparency color in the ImageList ).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is it possible to define and access a property as an array? I don't mean the "public <type> this[int index]", but something like this:
public string myStringProperty[int index]
{
get
{
return someFunction(index);
}
set
{
someVariable[index] = value;
}
}
Then, access it like this:
myStringProperty[x] = "abc";
Thanks!
Len
|
|
|
|
|
No, but if your property type is a list, the list itself will have an indexer. Just use a highly-coupled list (perhaps create a list, passing a reference to your object in question with things like someFunction and someVariable as internal members to the object.
In any case, this is a case for methods; what's wrong with methods?
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I was hoping to read from/write to the property like a typical variable. It's more flexible than creating methods to read and write.
Thanks anyway!
Len
|
|
|
|
|
Yeah, um, passing a parameter to an indexer property is SO much different that calling a method that takes the same parameter.
Even when using reflection these two things can be treated the same way since both PropertyInfo and MethodInfo derive from MemberInfo so using the MemberInfo abstract class makes it transparent.
Flexibility is in the design by the developer.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello, as you probably already know that I'm a n00b of C# and programming.
Here's what I want to make but I couldn't find any example to follow.
I want to make a windows form application, when you run the application it will launch a console/dos application with it, the windows form application will check every 60 seconds to see if the dos application is still running or not, if the dos application crashed the windows form application will relaunch the dos application, I also want to make a output box in the windows form application so whatever is displayed in the dos application will display in the windows form application's output box, and it would be nice if I can run the dos application within the windows form application, so it will save some taskbar space =^^=
Please don't tell me to go read MSDN Library, it's 2GB of files and I wouldn't even know where to start, just give me examples and tell tell me the syntax since I'm a n00b, but I'm pretty sure this isn't hard to do for you advanced C# programmers, so help a n00b out ^__^;
|
|
|
|
|
C# n00b wrote:
Please don't tell me to go read MSDN Library, it's 2GB of files and I wouldn't even know where to start
That's why it has a table of contents and a search facility.
C# n00b wrote:
just give me examples and tell tell me the syntax since I'm a n00b
And such you will always be, if you refuse to learn how to research things for yourself.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Take a look at the Process class in System.Diagnostics. You use the static method Process.Start to start a process. You can use the Process.WaitForExit to wait until it ends and launch it again if you'd like.
As far as redirecting the output of a console application, take a look at the ProcessStartInfo class that can be used as a parameter for the Start method. You can redirect standard output, input, and error from/to a console application using this class's various properties.
Process.Start will return an instance of the Process class, and if you set the ProcessStartInfo properties up, you can then use things like Process.StandardOutput as a stream to read out of.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
it would help if you can write some codes =^^=
I just started C# few days ago.
|
|
|
|
|
Have you done any programming before? You should probably start with simpler programs than this if you're new to programming. You should grab a book or look at sample programs and websites etc.
I once wrote a program to automate a console application (GPG) and I ended having to create threads to properly read the output of the program to avoid locking on reads of standard output. The threads brought on the need for syncrhonization objects. It's not the easiest task in the world.
Posting the code for all of this would probably do more harm than good if you're really wanting to learn. It would also be a pain for me to cut out the relevant sections and still give you something that compiles (since I'm guessing a snippet wouldn't do you any good).
In any event, if you post a program that launches another program and describe what's wrong with it, I'll take a look at it and get you further along.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
You can tell by reading my name that I'm a C# n00b and I haven't done any programming in the past, I heard start clean from C# would prevent you from getting bad habit, so here I am struggling through sam's teach yourself visual studio .net in 21 days =^^=
but I really want to make this program for my own personal use, it would help if you can give me more hint, so far I've only understand how to use Process.Start("dos.exe");
but I dunno how to make my program to check and see if the dos program is already started before it start the dos program, I tried to use if ... else but it give me error and say you can't use that in the if()
is there a way I can reach you where I can talk to you in instant msg or irc channel?
|
|
|
|
|
What did you try to put in the if statement? It sounds like you might be lacking some understanding of C# syntax in general. I think it's more important to understand this type of thing than doing arbitrary tasks like running programs. I know you're excited, but you really should learn to walk before you run. If you're new to programming in general, you should start with very easy tasks to gain understanding. Something simple like "Print the first 100 multiples of 5" or some such sillyness.
In any event, for determining if a program is already running, take a look here. The first reply to the question deals with getting a list of the running processes and checking their names. In the case of that thread, he was comparing it to the currently running program, but in your case it will be whatever the name of the program you're looking for.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
i don't quite understand that one, it's a little weird, it seems like it's used for the current application that it's making, but I using the application to check an external dos application, not the current application.
also, how do you make a monitor to monitor the status of the dos application, so when the dos application crash, the windows application will relaunch it.
I know i'm not suppose to jump ahead to do things that's too hard for a beginner, but i'm in need for this little tool and there's no other program would do this, so I have to put myself in this situation and beg for hints from you X_x;
http://www.shintasoft.com
Bring you English Version Super Robot Wars games
|
|
|
|
|
Yep. I mentioned you'd want to change this in your program. These lines...
Process proc = Process.GetCurrentProcess();
Process[] procs = Process.GetProcessesByName(proc.ProcessName);
...get the current process (and store it in a variable named proc). Then the next line of code gets all of the processes running on the machine with a name that it gets from proc.ProcessName (the name of our current process). In other words, it gets all of the processes running that have the same name as the currently running process. In your case, you'd just want something like this:
Process[] procs = Process.GetProcessesByName("foo.exe");
That's assuming you're looking for a program running called "foo.exe". You'd want to change that obviously or make it a variable instead of hardcoding (for the most part, you should never "hardcode" stuff like that). The thing you'll have to make sure of most likely is there's only one instance running. If the length of the procs array is more than 1, that means more than one instance of "foo.exe" is running in this case. If there's no instances running (length is 0), then you need to start the first one.
In any event, you should have one instance of the class Process that you'll be monitoring (either the one you got from GetProcessesByName or the one you'll get when you call Process.Start). At that point, you can call Process.WaitForExit on that instance. So for instance, if you had the Process in a variable called proc, you would do something like this:
proc.WaitForExit()
That would wait until it exits. If you only want to wait a certain amount of time, you can use the version that allows you to specify how many seconds to wait for it to exit. Something like this:
bool exited = proc.WaitForExit(10000);
if (exited)
{
}
else
{
}
Of course, you probably want to wait an indefinite amount of time, so you'll want the version of WaitForExit that takes no parameters and is a void return.
Here's a quick and dirty little program that monitors for calculator and launches one if it's not working. It's fairly self explanatory, but let me know what doesn't make sense in this example:
using System.IO;
using System.Diagnostics;
class BS
{
static void Main()
{
foreach (Process p in Process.GetProcesses())
{
System.Console.WriteLine("Found process:{0}", p.ProcessName);
}
Process ourProc;
Process[] procs = Process.GetProcessesByName("calc");
if (procs.Length == 0)
{
System.Console.WriteLine("An instance of calc.exe was not running, launching one...");
ourProc = Process.Start("calc.exe");
}
else if (procs.Length == 1)
{
System.Console.WriteLine("Found an instance of calc.exe to monitor.");
ourProc = procs[0];
}
else
{
System.Console.WriteLine("Don't know which calc.exe to monitor...");
return;
}
while (true)
{
ourProc.WaitForExit();
ourProc = Process.Start("calc.exe");
}
}
}
I tested this on Longhorn, but I'm sure it will work on every OS that .NET runs on...
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbin
|
|
|
|
|
Hello,
Does anyone know if there is any way to add a condition to your setup project so that the user can choose if they want a desktop shortcut or a program menu by selecting a checkbox. I know that you can use conditions on files, but I can't get it to work with shortcuts. I tried to apply the condition to the folders instead of the shortcuts themselves, but the setup program doesn't seem to care. It just ignores if the checkboxes are checked or unchecked. Is there another way to do this? I don't want to force desktop shortcuts or program menu groups upon the user.
Thanks,
Blake
|
|
|
|
|
Not with VS.NET's Windows Installer project designer. It provides very little exposure for the tables that make up an installer database.
Typically - in a real Windows Installer editor (Wise, InstallShield, Microsoft's Orca, etc.) - the shortcut should be associated with the component that contains the executable (which should be the key file). In some cases, developers put the shortcut in a different component and add a condition to it. If your app only installs a couple shortcuts and you want one option that determines if they are installed or not, you can have a dialog control (checkbox, for example) that sets a property that is used in the InstallExecuteSequence table for the Condition field.
In either case, though, VS.NET won't let you do it. You can download the Windows Installer SDK (part of the Platform SDK) from MSDN and use the Orca utility (the MSI is downloaded, but you have to install it manually for some strange reason) to edit the tables manually after the MSI is compiled.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I need to display an Image in a datagrid en windows forms, someone knows an easy way to do it? I had tried with some "EasyDatagrids" but I have to pay for that, some knows how to draw an image in a Datagrid?
thanks in advance
Pato
|
|
|
|
|
What if you put a placeholder in a column, impliment and OnInit method, and insert the image there ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
An Image or something? do you have and example?
|
|
|
|
|
There is an Image class in ASP.NET, I presume that WinForms has a similar class. So look it up in the MSDN, and check out how to create one dynamically.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|