|
Thanks for reply
Dave, you are right, but i know another way
I think you mean that if an application is prevented from being run by hash code way, it can not be run by another application (mine) as well.
If you mean this, then i have a tricky solution for that, i manipulate the application binary source "exe" file (only a bit toggle is sufficient) so that it works fine, store it in the resource of my application. I extract it only while needed and then will be removed.
I know this way is not perfect, but the users of my application are not professional.
So my only problem is the question in the title of thread.
|
|
|
|
|
Mehrdad Seyrafi wrote: If you mean this, then i have a tricky solution for that, i manipulate the application binary source "exe" file (only a bit toggle is sufficient) so that it works fine
There's no need for this at all.
Mehrdad Seyrafi wrote: store it in the resource of my application. I extract it only while needed and then will be removed.
And there is still nothing from preventing the user from just copying the .EXE to another location and running it from there. If the app also needs to be installed or needs come components to be registered, well... let's just say this is getting more ugly than it already is.
There is simply no good method for doing this.
|
|
|
|
|
Hi, I got a problem with my datagridview sorting. When I use AutoGenerateColumns=true. It can do sorting. But when I set AutoGenerateColumns = false, I can't do the sorting. What am I missing here. Thanks.
|
|
|
|
|
|
Isn't there any simple solution, because it is working before the AutoGenerateColumns
|
|
|
|
|
Hello.
I am creating a program, where i need to have the 29 letter in Textbox1 to be replaced by t
Also xxxxxxxxxxxxxxxxxxxxxxxxxxx(t)xxxxxxxxxxx
Also.. My users, shall paste a link, there is about 30-40 letters, and number 29 shall be changed to a t.
Is that possible?
Regards Ahlmo
|
|
|
|
|
yes.
|
|
|
|
|
Can you show me ?
Also a tutorials or an example.
|
|
|
|
|
what you ask for is elementary string manipulation, read up on the String class, and start using some of its methods. If you don't feel comfortable programming in C# (or programming in general), I suggest you start by buying and studying an introductory book.
|
|
|
|
|
I have many books about c#, but can you show me an example for it ?
|
|
|
|
|
ahlm wrote: I have many books
Having them is not enough, you should study them. I'm not in a spoon feeding mood right now.
|
|
|
|
|
But do u know some good book titles then? I really need to learn it
|
|
|
|
|
It depends on your background.
I suggest you visit a book store and choose one or two. Read more here[^]
Year ago I liked "Microsoft Visual C#.NET Step by Step" by Sharp and Jagger.
|
|
|
|
|
Luc's being a 'meanie'! (although he makes a very good point)
Everything you need to do this as Luc said is in the String class - MSDN link[^].
A quick way to find out how to do something is to type the question into a search engine. For example, "how to replace a letter in string C#" with google returns this[^]. These results show many different ways of doing exactly what you want.
I don't mean to be sarcastic or condescending, but basic use of a search engine is an absolute requirement which you should always use as your first point of reference before asking on any programming site as you can be 100% sure that it has been asked and answered before unless it's a particularly technical or obscure question.
Once you have some answers, typing the class.methodname and appending MSDN will give you links to Microsoft's own documentation so you can read up on the finer points of the implementation possibilities of the options available.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks.
So this should work?
string str = "codeproject.com/script/";
str = str.Replace("codeproject.com/script/", "codeproject.com/scripl/"); <----
Also i have changed a "l"
|
|
|
|
|
That will work but it's not very versatile - if you just need to replace the word 'script'with 'scripl' then you should just use that part
string str = "codeproject.com/script/";
str = str.Replace("script", "scripl"); This doesn't deal with your original problem though, replacing one character a specific position with another. You could hard code something to alter just the 29th to 't', but then it wouldn't be reusable. I would create a method like
public static string ReplaceCharacter(string original, int index, char newChar)
{
} There are several methods which you will have come across through the google link.
There is String.Replace , but that replaces all occurences of a character or string inside the string plus you can't specify a position.
You could build a new string using a StringBuilder using the Substring up to the required character, appending the character you want and then appending the Substring after it. This would work but is a bit messy.
The method I would prefer is to convert the string to a char[] , change the character at the correct index then create a new string from the array. This would look something like this:
public static string ReplaceCharacter(string original, int index, char newChar)
{
if (index < original.Length)
{
char[] chars = original.ToCharArray();
chars[index] = newChar;
return new string(chars);
}
else
return original;
}
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I have a class that inherits System.ServiceProcess.ServiceBase and is overriding the OnStart (string[] args) method. Where do I call base.OnStart(args)? At the beginning of the method or at the end?
protected override void OnStart(string[] args)
{
base.OnStart(args);
}
Or:
protected override void OnStart(string[] args)
{
base.OnStart(args);
}
|
|
|
|
|
Normally OnXxx methods are used for raising events (and occaisionaly other logic that relates to an action but that should be documented). If your code in Do stuffrelies upon this event already being raised (or any other logic that might be in the base method being applied) then you should call it first. If it's important that your Do stuff is done before any events are raised etc then you should call it afterwards. If it doesn't matter then it doesn't matter!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
DaveyM69 wrote: If it doesn't matter then it doesn't matter!
when you're right, you're right indeed!
|
|
|
|
|
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Sorry for not getting back sooner. In the OnStart method I'll be creating a couple of threads, a dozen or sockets and creating some objects but they won't depend on base.OnStart().
Let's say that something in my OnStart fails (file not found for example), how would I report that startup has failed and stop the startup of the service? Do I simply not call base.OnStart()?
modified on Sunday, December 6, 2009 9:15 PM
|
|
|
|
|
That depends on what else you do in your OnStart; I call base.OnStart in the middle:
protected override void
OnStart
(
string[] args
)
{
# if DEBUG
System.Threading.Thread.Sleep ( 60000 ) ;
# endif
this.oktoproceed = true ;
base.OnStart ( args ) ;
if ( this.when != null )
{
this.when.Start() ;
}
LogMessage ( this.ServiceName + " started" ) ;
return ;
}
(The Sleep gives me time to attach the debugger. when is a System.Timers.Timer .)
|
|
|
|
|
hey guys,
i wanted to program a windows CE device by c# and my purpose is to print a simple page. but in 'device application' windows form, there is no 'PrintDialog' nor 'PrintDocument' (and other necessary) classes for me to manage a print .
how can i print through a windows CE device?
much appreciated.
modified on Saturday, November 28, 2009 1:32 PM
|
|
|
|
|
How do you attach a printer to a windows CE device ? Do they have USB ports and printer drivers ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
yes exactly. i have a usb printer connected to my device and my windows recognizes it and the driver.
i can print with other applications in windows CE (like microsoft word) but i want my own application to print a page. how is it?
thanks.
|
|
|
|