|
1) You can use a static variable in yoor program befor Application.Run(MainForm) like bool _isRunning = false as initial value and upate it in Form.Closed event to false. This idea is simple but not efficient, good and professional and secure.
2) You can store a registry key and check it before Application.Run(MainForm) to see if your application is already running or not. Better but not secure.
3) use Process.GetCurrentProcesses() method and do a search in the result set to check if your process exists. Much more reliable than all but you shoul have a unique process name.
hope this helps...
|
|
|
|
|
hi,
iam krishna working on .net techonologies. In my current project i have a problem in admin module ie., My admin modules consists of 26 links (anchor tag),which will redirect to specified page. each link assigned a unique id. what my problem is when iam logging on to admin panel , depending upon the role of the user who is logging onto admin panel i have to hide the links for the users depending permissions given to them. For this what i have done is i have stored the user roles,formnames , formids,permission(as enabled/disabled)into the database.for Providing the permission for the users the administartor has a user interface,while iam retrieving the enabled formids of a user iam getting the formids into a variable, but what i have to do is, i have to match the ids with the hyperlink ids and make the hyperlinks visible or invisible.
could any one give me the suggestions or solution to this problem.
thanx in advance.
with regards,
krishna
|
|
|
|
|
Its easy but you are making your application very complicated
i don't know why are checking Id if form to control id ?
Store credentails in the database specifying which link should not display for perticular user role and make all those link disable in page load
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
I would certainly suggest that use LinkButton and set its visible property to true or false as depending on role
|
|
|
|
|
hi everybody,
i want to disable CTRL+ALT+DEL,ALT+F4 and ALT+TAb keys through
c# program how can i achieve it.please send some clue if possible please
send some sample code.
|
|
|
|
|
You cannot disable Ctrl-Alt-Delete.
|
|
|
|
|
As Jon said, Windows will not allow you to disable CTRL-ALT-DEL. This is because this particular shortcut is used to signal to the Windows OS that you want to perform some critical action - log off, terminate a program, etc. In fact, in some Windows setups, you are required to press CTRL-ALT-DEL before you login to the system. This is so that you know that you're typing your username and password into a real Windows OS login dialog - not some spoofer.
That said, it sounds like you might be trying to write a screensaver program. Don't worry about those key combinations. Just write your program as a normal .EXE file, then when it is compiled change the file extension to .SCR. Then right-click on the file from Explorer and hit Install. You'll now be able to use this as a screensaver, and Windows should take care of those pesky key combinations for you automatically.
|
|
|
|
|
Use keyboard hooking to do whatever you want. This way, you can hook all the key events in windows for all windows and cancel the ones you don't want to be processed by "your Window".
this topic is not a small one and requires experience. Please checkout google for more information and source code examples.
|
|
|
|
|
I need a regular expression which find the word inside < and >.
For example:
In the following expression,
<this.text> + <<another.text>>
it should only find <this.text>
It should only search words starting and ending with <> not <<>>.
|
|
|
|
|
Is this what you want?
[^<](?<Text><[^>]*>)[^>]
This will result in a named capture called "Text" that contains the string including < and > (but not << and >>) as you specified. I guess you'll have to try it out with a larger data set to see if it meets your needs completely.
-- modified at 5:02 Friday 4th May, 2007
Previous post got buggered w/ HTML tags... ;]
--
Umm... what's a .sig? ;]
|
|
|
|
|
Sorry, have to correct myself yet again! ;] My previous expression would not match at the very beginning or end of a string, so we need to use Zero-width negative lookbehind assertion (?<!) and Zero-width negative lookahead assertion (?!) to make sure that if there is not anything preceding or following the string, it'll match as well. So, here's the full expression:
(?<!<)(?<Text><[^<>]*>)(?!>)
--
Umm... what's a .sig? ;]
|
|
|
|
|
Thanks
its working fine, is there any way that we can restrict the selection by the no of < and > signs. For Example if i want it neglect <<< and select <<.
|
|
|
|
|
Sure - you could simply put an additional < and > on the inside part of the expression, as follows:
(?<!<)(?<Text><<[^<>]*>>)(?!>)
Then you'll match on anything enclosed in << and >>, but not any of < and >, <<< and >>> and more such as <<<< and >>>>.
--
Umm... what's a .sig? ;]
|
|
|
|
|
Thanks alot ...
|
|
|
|
|
Hi,
I used TCPClient for Http Request. and here is my code
TcpClient client = new TcpClient("www.google.co.in", 80);
NetworkStream stream = client.GetStream();
string str = "GET / HTTP/1.1 \r\n Host: www.google.co.in \r\n Accept: */*
\r\n Connection: keep-alive\r\n ;
byte[] send = Encoding.ASCII.GetBytes(str);
stream.Write(send, 0, send.Length);
byte[] bytes=new bytes[client.ReceiveBufferSize];
if (stream.DataAvailable)
{
int count = stream.Read(bytes, 0, client.ReceiveBufferSize);
}
String data = Encoding.ASCII.GetString(bytes);
After Sending my request, i am not getting the response.I think the problem
is with my request. How my request should be if i use TCPClient.
Thanks in advance
Sakthi.
|
|
|
|
|
Hi
I got the response as i assumed my request string should be like
string str = "GET / HTTP/1.1 \r\n Host: www.rediffmail.com \r\n Accept: */* \r\n Connection: keep-alive \r\n\r\n";
Regards
Sakthi
|
|
|
|
|
Hi,
You better use the HTTPResonse handler in C#
ie:
using System.Net;
...
...
public string WebResponse(string URL)
{
if (!URL.ToLower().StartsWith("http://") || !URL.ToLower().StartsWith("https://"))
URL = "http://"+ URL;
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(URL);
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
return WebResp.StatusDescription;
}
|
|
|
|
|
Hi,
I can use HttpWebRequest for sending Request Messages.
But for each request, i have to create httpwebrequest object and i have to
establish connection. Is it possible to use the same connection for more than
one request in httpwebrequest.
Regards
Sakthi
|
|
|
|
|
Something like this?
using System.Net;
namespace Sakthi
{
public class SakthiForRequest
{
HttpWebRequest WebReq;
HttpWebResponse WebResp;
public string SakthiRequest()
{
string request[] = new string[10];
request[0] = "www.micrsoft.com";
request[1] ............
request[9] = ......;
string webresponse[] = new string[10];
for (int i =0 ; i < 10; i++)
{
webresponse[i] = WebResponse(request[i]);
}
}
}
public string WebResponse(string URL)
{
if (!URL.ToLower().StartsWith("http://") || !URL.ToLower().StartsWith("https://"))
URL = "http://"+ URL;
WebReq = (HttpWebRequest)WebRequest.Create(URL);
WebResp = (HttpWebResponse)WebReq.GetResponse();
return WebResp.StatusDescription;
}
}
|
|
|
|
|
I m trying to create a registry editor using c#.net. i have populated all the registry keys and subkeys in a treeview. I want to display valuenames, type and values in a listview when I click a subkey in treeview. how can i do that. pls help me out of this problem.
Regards
Paramhans
|
|
|
|
|
you can get value names by RegistryKey.GetValueName() it will give string array. you can get their values by RegistryKey.GetValue("name") and if you are using .net 2.0 then you can also get their type/kind by RegistryKey.GetValueKind("name").
Regards
Shajeel
|
|
|
|
|
Hi Friend'z...
Can anyone explain me about Indexers with real time example. Where should we use indexers in programs? Why should we use indexers? what r the advantages of Indexers in c#?
thanks in advance...
shah_tech,
Tr. Systems Engineer
|
|
|
|
|
Hi Shah
Indexers allows you to access the object like you are accessing the array .
Indexers permit instances of a class or struct to be indexed in the same way as arrays. Indexers are similar to properties except that their accessors take parameters
<br />
class SampleCollection<T><br />
{<br />
private T[] arr = new T[100];<br />
public T this[int i]<br />
{<br />
get<br />
{<br />
return arr[i];<br />
}<br />
set<br />
{<br />
arr[i] = value;<br />
}<br />
}<br />
}<br />
<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
SampleCollection<string> stringCollection = new SampleCollection<string>();<br />
stringCollection[0] = "Hello, World";<br />
System.Console.WriteLine(stringCollection[0]);<br />
}<br />
}<br />
<br />
<br />
Indexers enable objects to be indexed in a similar way to arrays.
A get accessor returns a value. A set accessor assigns a value.
The this keyword is used to define the indexers.
The value keyword is used to define the value being assigned by the set indexer.
Indexers do not have to be indexed by an integer value; it is up to you how to define the specific look-up mechanism.
Indexers can be overloaded.
Indexers can have more than one formal parameter, for example, when accessing a two-dimensional array.
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
I had problem with listbox in c#:
the problem is i have to listboxes the items in listbox1 moves to listbox2
and next button is pressed it moves to the nextpage if the items in listbox2 are moved back to listbox1 and next button is pressed it should show error message. upto here the functionality is working fine
the problem is there is a link below to delete the items in listbox1
once i deselect the items in listbox2 and then delete the items in listbox1
and press the nextbutton the message is not fired instead it is navigating to the next page.
I used javascript for moving the selected items from listbox1 to listbox2 and for deleting the items in listbox1
i require solution to this problem
any one please help me out in solving this problem
Thanks ®ards
giribabu
hi
|
|
|
|
|
Check your logic on next buttion click there might be any problem can you post the javascript
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|