C# Make a window program in system tray, hidden in task bar, and hidden in alt-tab list
September 18th, 2009 Phanix讓視窗程式只在 system tray 中顯示, 不會出現在工作列(task bar)中, 也不會出現在 alt-tab 清單裡頭
Read the rest of this entry / 繼續閱讀 »
讓視窗程式只在 system tray 中顯示, 不會出現在工作列(task bar)中, 也不會出現在 alt-tab 清單裡頭
Read the rest of this entry / 繼續閱讀 »
有些時候為了 security 問題或者想要詳細紀錄使用者存取網路磁碟機或目錄中資料的情況, 所以會另外建立帳號並透過程式來存取網路磁碟機, 而不讓使用者直接用他的帳號密碼來存取, 這時候就需要讓程式可以建立網路磁碟機與中斷連線.
我自己比較喜歡第一個方式, 相對來說簡單許多.
Read the rest of this entry / 繼續閱讀 »
in Properties\AssemblyInfo.cs
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
UDP Server
private void ServerBroadcastThread()
{
int GroupPort = 15000;
UdpClient udp = new UdpClient();
udp.EnableBroadcast = true;
IPEndPoint groupEP = new IPEndPoint(IPAddress.Broadcast, GroupPort);
string str4;
byte[] sendBytes4;
while (true)
{
str4 = "Is anyone out there?";
sendBytes4 = Encoding.Default.GetBytes(str4);
udp.Send(sendBytes4, sendBytes4.Length, groupEP);
Thread.Sleep(10000);
}
}
UDP Client
private void ClientBroadcastThread()
{
UdpClient receivingUdpClient = new UdpClient(15000);
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
string returnData;
byte[] receiveBytes;
while (true)
{
try
{
// Blocks until a message returns on this socket from a remote host.
receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
returnData = Encoding.ASCII.GetString(receiveBytes);
MessageBox.Show(returnData);
}
catch (Exception e)
{
//Console.WriteLine(e.ToString());
}
}
}
While using some library functions in Visual Studio .NET, you can always find such kind of descriptions which help you to get some idea of parameters and functions.
However, how to provide such kind of descriptions in your class libraries?
Plz refer this! http://www.codeproject.com/KB/XML/csharpcodedocumentation.aspx?msg=1643354
While using MySQL ODBC to execute sql statements, only single sql statement is allowed for execution by default. If you want to execute multiple sql statements at once, you have to enable the multiple statements setting in MySQL ODBC.
程式執行後以最小化的方式執行,即不會出現在工作列上,而會出現在tray裡頭。而在 tray icon 上可以點滑鼠右鍵來彈出功能表單(menu),進行各功能選擇(如結束等)。
有時候為了要偷偷做一些事情, 所以會想要讓程式以無視窗在背景執行, 而要做出這樣的程式其實方法很簡單
這樣就可以了, 當發現到這樣做就搞定的時候還有點訝異怎麼這麼容易…
Just wake up from noon break, I think I have to write down some day-to-day things.
那個\0很重要。
using System.Runtime.InteropServices;
public bool DoDBConnect(string strDSN,string strUID,string strPWD)
{
try
{
strConn = "DSN=" + strDSN + ";UID=" + strUID + ";PWD=" + strPWD + ";";
cn = new OdbcConnection(strConn);
cmd = new OdbcCommand();
adp = new OdbcDataAdapter();
cmd.CommandType = CommandType.Text;
cmd.Connection = cn;
}
catch
{
return false;
}
return true;
}
[
DllImport("ODBCCP32.dll")
]
private static extern bool SQLConfigDataSource(IntPtr hwndParent, int fRequest, string lpszDriver, string lpszAttributes);
public bool CreateODBCDSN(string strDSN, string strServer, string strDB, string strDescription)
{
string strSQL = "SERVER=" + strServer + "\0";
strSQL += "DESCRIPTION=" + strDescription + "\0";
strSQL += "DSN=" + strDSN + "\0";
strSQL += "DATABASE=" + strDB + "\0";
strSQL += "trusted_connection=no\0";
return SQLConfigDataSource((IntPtr)0, 4, "SQL Server", strSQL);
}