Click here to Skip to main content
15,900,511 members
Home / Discussions / C#
   

C#

 
AnswerRe: Need Help Creating Pop Up WinForm Pin
ilan_dalal22-Feb-06 2:25
ilan_dalal22-Feb-06 2:25 
QuestionVertical alignment of text WITHOUT rotating graphics object Pin
buelentc21-Feb-06 11:43
buelentc21-Feb-06 11:43 
AnswerRe: Vertical alignment of text WITHOUT rotating graphics object Pin
Judah Gabriel Himango21-Feb-06 13:32
sponsorJudah Gabriel Himango21-Feb-06 13:32 
QuestionHow to Print a Page in Visual Studio 2003 by using C# ? Pin
Abubakarsb21-Feb-06 11:42
Abubakarsb21-Feb-06 11:42 
QuestionHow to use OpenGL in c# ? Pin
hdv21221-Feb-06 11:38
hdv21221-Feb-06 11:38 
AnswerRe: How to use OpenGL in c# ? Pin
Judah Gabriel Himango21-Feb-06 11:55
sponsorJudah Gabriel Himango21-Feb-06 11:55 
QuestionHow to Check For Network Connection? Pin
cyrus_thevirus21-Feb-06 11:32
cyrus_thevirus21-Feb-06 11:32 
AnswerRe: How to Check For Network Connection? Pin
gnjunge21-Feb-06 23:36
gnjunge21-Feb-06 23:36 
You can do this two ways: the nice one and the bold one.
Let's start with the bold one.
try {
   //CONNECT TO YOUR SERVER
}
catch  {
   //NO CONNECTION, SO DO SOMETHING
}
finally {
   //CLOSE CONNECTION
}

The nice way is to actually check using the WinAPI if there is a connection.
The following functionality checks for an internetconnection:
[DllImport("WININET", CharSet=CharSet.Auto)]
static extern bool InternetGetConnectedState(
    ref InternetConnectionState lpdwFlags,
    int dwReserved);

[Flags]
    enum InternetConnectionState: int
{
    INTERNET_CONNECTION_MODEM = 0x1,
    INTERNET_CONNECTION_LAN = 0x2,
    INTERNET_CONNECTION_PROXY = 0x4,
    INTERNET_RAS_INSTALLED = 0x10,
    INTERNET_CONNECTION_OFFLINE = 0x20,
    INTERNET_CONNECTION_CONFIGURED = 0x40
}

[DllImport("wininet.dll", SetLastError=true)]
static extern int InternetAttemptConnect(int dwReserved);


Here is a simple example showing a messagebox if with the connection state:
InternetConnectionState flags = 0;
InternetGetConnectedState(ref flags, 0);
MessageBox.Show(String.Format("InternetState : {0} - {1}",(InternetGetConnectedState(ref flags, 0)?"ONLINE":"OFFLINE"),flags));


I suggest going to http://www.pinvoke.net[^] for more win API for connection checks.
QuestionObject Binding - RDLC report (nested obj's) Pin
Susan Hernandez21-Feb-06 9:59
Susan Hernandez21-Feb-06 9:59 
QuestionCompare 2 digits Pin
cppdotnet21-Feb-06 9:34
cppdotnet21-Feb-06 9:34 
AnswerRe: Compare 2 digits Pin
Guffa21-Feb-06 10:07
Guffa21-Feb-06 10:07 
GeneralRe: Compare 2 digits Pin
cppdotnet21-Feb-06 10:31
cppdotnet21-Feb-06 10:31 
QuestionTristate checkboxes in TreeView? Pin
Luis Alonso Ramos21-Feb-06 9:26
Luis Alonso Ramos21-Feb-06 9:26 
AnswerRe: Tristate checkboxes in TreeView? Pin
Joe Woodbury21-Feb-06 10:41
professionalJoe Woodbury21-Feb-06 10:41 
AnswerRe: Tristate checkboxes in TreeView? Pin
Joel Lucsy22-Feb-06 13:21
Joel Lucsy22-Feb-06 13:21 
QuestionVB to C# codes Pin
superPaul10121-Feb-06 8:34
superPaul10121-Feb-06 8:34 
AnswerRe: VB to C# codes Pin
Wjousts21-Feb-06 8:38
Wjousts21-Feb-06 8:38 
GeneralRe: VB to C# codes Pin
superPaul10121-Feb-06 8:41
superPaul10121-Feb-06 8:41 
GeneralRe: VB to C# codes Pin
Wjousts21-Feb-06 8:46
Wjousts21-Feb-06 8:46 
GeneralRe: VB to C# codes Pin
superPaul10121-Feb-06 8:50
superPaul10121-Feb-06 8:50 
AnswerRe: VB to C# codes Pin
Dave Doknjas21-Feb-06 15:11
Dave Doknjas21-Feb-06 15:11 
QuestionWeird IComparer behavor in DataGridView Pin
Wjousts21-Feb-06 8:25
Wjousts21-Feb-06 8:25 
QuestionApp in Taskbar like Media Player Pin
DeepToot21-Feb-06 7:21
DeepToot21-Feb-06 7:21 
AnswerRe: App in Taskbar like Media Player Pin
hard.disk21-Feb-06 8:01
hard.disk21-Feb-06 8:01 
GeneralRe: App in Taskbar like Media Player Pin
DeepToot21-Feb-06 8:04
DeepToot21-Feb-06 8:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.