|
I guess you have to write InternetGetConnectedState(out int Description, ... .
|
|
|
|
|
change to this line...
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
|
No Prob
in case you dont know what the issue was it is because the 'out' keyword needs to go before the type (int)
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi guys,
i've done a site that will allow SMSs be sent to members' mobile phones whenever there's an important msg to be passed.
However, i can't programmatically retrieve values from the server and send the SMSs.
i need to know how to do this without anyone doing it manually. like just set a date and time, and then it'll execute.
thanx.
He who goes for revenge must first dig two graves.
|
|
|
|
|
Hi,
Please give me some links of speech to text convertion project.
what are the concept behind this to develop this application.
Thankyou,
YPKI
|
|
|
|
|
ypki wrote: Please give me some links of speech to text convertion project.
what are the concept behind this to develop this application.
It is very difficult to write code to wreck a nice beach and often the results are poor. I suggest you might want to look into existing libraries or frameworks that do this.
|
|
|
|
|
Colin Angus Mackay wrote: wreck a nice beach
ROFL
var question = (_2b || !(_2b));
|
|
|
|
|
Take a look Here[^].
Those tools are not free, though.
|
|
|
|
|
Hello there,
I am working on a small Windows form, where I've to implelent the LinkLabel control to link my form with www.microsoft.com. Below is the code:
private void linkLabel1_LinkClicked(object sender,LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(www.microsoft.com);
}
But when I debug the code, I get an error which is like this "The name www does not exist in the current context".
Can anyone please tell me, whats the correct code for the LinkLabel event handler, such that my form connects to microsoft.com.
Your help would be appreciated! Thanx.
|
|
|
|
|
Put the URL in quotes.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanx for helping me out. You guys see, I was doing such a silly mistake! But a lot of thanx to u both. Hope to recieve more help from u folks in future also. Take care....
|
|
|
|
|
Just as a tip, you could make that event slightly more situation-generic by starting e.Link, instead of a hardcoded string. Then you simply have to set the LinkLabel's Links property accordingly, and you don't have to dip into code in order to change the link destination
|
|
|
|
|
Hi there guys,
where should I place e.Link as suggested by Computafreak?
I am coding the the LinkLabel Event Handler with:
{
System.Diagnostics.Process.Start("www.microsoft.com");
}
Where should I add e.Link to make it more situation-generic?
|
|
|
|
|
You'd need to do something like this (assuming you just want the whole text to be one link - you can have a link for as many characters as there are in the Text!).
linkLabel1.Text = "Go to Microsoft's web site";
linkLabel1.Links[0].LinkData = "http://www.microsoft.com";
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (e.Link.LinkData is string)
{
string url = (string)e.Link.LinkData;
System.Diagnostics.Process.Start(url);
}
}
[Edit] Just had a quick play and the above works fine, but you could maybe improve it with something like this:
string keyText = "Microsoft";
linkLabel1.Text = string.Format("Go to {0}'s web site", keyText);
linkLabel1.Links[0].Start = linkLabel1.Text.IndexOf(keyText);
linkLabel1.Links[0].Length = keyText.Length;
linkLabel1.Links[0].LinkData = string.Format("http://www.{0}.com", keyText); [/Edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
modified on Wednesday, April 1, 2009 7:36 AM
|
|
|
|
|
Hi, I've entered this code in the LinkLabel_LinkClicked Event Handler, as suggested by you (Dave):
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (e.Link.LinkData is string)
{
string url = (string)e.Link.LinkData; System.Diagnostics.Process.Start("www.microsoft.com");
}
}
//Please see whether I have enetered the correct code!
But tell me where do I enter this code, in which event:
linkLabel1.Text = "Go to Microsoft's web site";linkLabel1.Links[0].LinkData = "http://www.microsoft.com";
|
|
|
|
|
I think you're getting a bit mixed up.
Work it out from the full sample below - I've just created a new project, and dragged a LinkLabel onto Form1.
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
linkLabel1.LinkClicked += new LinkLabelLinkClickedEventHandler(linkLabel1_LinkClicked);
string keyText = "Microsoft";
linkLabel1.Text = string.Format("Go to {0}'s web site", keyText);
linkLabel1.Links[0].Start = linkLabel1.Text.IndexOf(keyText);
linkLabel1.Links[0].Length = keyText.Length;
linkLabel1.Links[0].LinkData = string.Format("http://www.{0}.com", keyText);
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (e.Link.LinkData is string)
{
string url = (string)e.Link.LinkData;
System.Diagnostics.Process.Start(url);
}
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanx Davey!
U did so much for me! U r great! Actually, I am not that expert like u guys. I am only a begineer, trying to figure myself out in the IT industry. Can u give me your Email address such that I can send u a greetings of compliment. Hope to hear from u soon in the forum.
Take care Genius!
Rajdeep
|
|
|
|
|
You're welcome. That's why we come here - to help, and be helped when needed.
We were all beginners at one time so don't worry about that, and welcome to CodeProject.
(You can email me through the link that's at the bottom of each post.)
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
No problem
I normally use my own version of the link label which I've just added a URL property to and overridden the OnClick so it starts the process automatically with no coding needed.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Forms;
namespace WinForms.Controls
{
public class URLLabel : LinkLabel
{
public URLLabel()
{
URL = "about:blank";
}
[DefaultValue("about:blank"),
Description("The URL that will launched in the default browser when the label is clicked.")]
public string URL
{
get;
set;
}
protected override void OnClick(EventArgs e)
{
try
{
Process.Start(URL);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
base.OnClick(e);
}
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I've not tested this, but have you tried something like System.Diagnostics.Process.Start("HTTP://www.microsoft.com"); ??
oooo, the Jedi's will feel this one....
|
|
|
|
|
Hi Everyone.
I'm pretty new to C#, and I'm having a bit of a problem. I have an application which will be saving passwords to an xml document, so I want to encrypt them. I have created some simple code which manages to encrypt the information but complains when I try to decrypt it with “Padding is invalid and cannot be removed”. I have tried different padding modes including PaddingMode.None with no luck.
I’m sure I'm missing something simple... Please can somebody help me???
Thanks
Code
class Program
{
static void Main(string[] args)
{
string Orig = "Paul Unsworth";
string Key = "as^le)ds~{3sjlk3*$ake^ia29?jf%a!";
string IV = "ad|k#f(*&lk$df()";
string Encrypted = Encrypt(Orig, Key, IV);
string Decrypted = Decrypt(Encrypted, Key, IV);
Console.WriteLine("Original Text:\r\n {0}", Orig);
Console.WriteLine("Encrypted Text:\r\n {0}", Encrypted);
Console.WriteLine("Decrypted Text:\r\n {0}", Decrypted);
Console.ReadLine();
}
static string Encrypt(string val, string key, string iv)
{
byte[] bVal = toBytes(val);
byte[] bKey = toBytes(key);
byte[] bIV = toBytes(iv);
MemoryStream ms = new MemoryStream();
Rijndael r = Rijndael.Create();
r.Key = bKey;
r.IV = bIV;
r.Padding = PaddingMode.PKCS7;
CryptoStream cs = new CryptoStream(ms, r.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(bVal, 0, bVal.Length);
cs.Close();
string result = toString(ms.ToArray());
ms.Close();
return result;
}
static string Decrypt(string val, string key, string iv)
{
byte[] bVal = toBytes(val);
byte[] bKey = toBytes(key);
byte[] bIV = toBytes(iv);
MemoryStream ms = new MemoryStream();
Rijndael r = Rijndael.Create();
r.Key = bKey;
r.IV = bIV;
r.Padding = PaddingMode.PKCS7;
CryptoStream cs = new CryptoStream(ms, r.CreateDecryptor(), CryptoStreamMode.Write);
cs.Write(bVal, 0, bVal.Length);
cs.Close();
string result = toString(ms.ToArray());
ms.Close();
return result;
}
static byte[] toBytes(string str)
{
ASCIIEncoding a = new ASCIIEncoding();
return a.GetBytes(str);
}
static string toString(byte[] b)
{
ASCIIEncoding a = new ASCIIEncoding();
return a.GetString(b);
}
}
oooo, the Jedi's will feel this one....
|
|
|
|
|
Hey Monkey,
Your problem seems a bit tough to me... why not consult some expert programmer and if possible shorten the code. Good programmers often find it harassing reading such long codes.
Happy Programming.....
|
|
|
|
|
Hmm forums say that this might be a problem if everything is not read to the end. Call cs.Flush() before you close the CryptoStream.
If this doesn't work, I would think about using an hash-algorithm because you don't need to decrypt the password ever again. Just encrypt the user input and check if this equals the stored hash before.
Regards
Sebastian
|
|
|
|
|
Thanks for your reply Sebastian.
I've tried cs.Flush() and unfortunatly it did not work.
The pain in the backside is I need to be able to decrypt the password, as it is for SQL Server Authentication. The app is to run/create a load of old long standing reports automatically, and for this, the User Name and Password need to be passed to SQL Server. (We have people unwilling to move away from excel workbooks to better reporting methods in this company )
Thanks for you help...
oooo, the Jedi's will feel this one....
|
|
|
|