Application Development

Software technique, Skills & Applications

Match September 30, 2008

Filed under: Uncategorized — meetme @ 12:59 pm

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] stdA = { “1″, “2″, “3″, “4″, “2″ };
            string[] optA = { “2″, “2″, “4″, “5″, “4″ };
            int[] stdU = { 0, 0, 0, 0, 0 };
            int[] optU = { 0, 0, 0, 0, 0 };

            int B = 0;
            int W = 0;

            for(int i=0;i < 5;i++)
            {
                if (stdA[i] == optA[i])
                {
                    B += 1;
                    stdU[i] = 1;
                    optU[i] = 1;
                }

                for (int j = 0; j < 5; j++)
                {
                    if (i != j)
                    {
                        if (stdA[i] == optA[j] && stdU[i] == 0 && optU[j] == 0)
                        {
                             W += 1;
                             stdU[i] = 1;
                             optU[j] = 1;
                         }
                    }
                }
            }

            Console.Write(“B=”+B.ToString() + “  W=”+W.ToString() );
            Console.Read();
        }
    }
}

 

Drag and Drop on a DataGridView July 7, 2008

Filed under: Uncategorized — meetme @ 6:53 pm

Here is a bit of sample code that allows you to drag and drop a cellvalue in a DataGridView (don’t forget to set the AllowDrop property of the DataGridView to true). Notice that you need to translate the X and Y properties of the DragEventArgs first (unlike the X and Y properties of the MouseEventArgs):
private void dataGridView1_MouseDown( object sender, MouseEventArgs e )
{
 DataGridView.HitTestInfo info = this.dataGridView1.HitTest( e.X, e.Y );
 if ( info.RowIndex != -1 && info.ColumnIndex != -1 )
 {
  Object value = this.dataGridView1.Rows[info.RowIndex].Cells[info.ColumnIndex].Value;
  if (  value != null )
  {
   this.dataGridView1.Rows[info.RowIndex].Cells[info.ColumnIndex].Value = null;
   this.DoDragDrop( value, DragDropEffects.Move );
  }
 }
}

private void dataGridView1_DragDrop( object sender, DragEventArgs e )
{
 Point p = this.dataGridView1.PointToClient( new Point( e.X, e.Y ) );
 DataGridView.HitTestInfo info = this.dataGridView1.HitTest( p.X, p.Y );
 if ( info.RowIndex != -1 && info.ColumnIndex != -1 )
 {
  Object value = (Object)e.Data.GetData( typeof( string ) );
  this.dataGridView1.Rows[info.RowIndex].Cells[info.ColumnIndex].Value = value;
 }
}

private void dataGridView1_DragEnter( object sender, DragEventArgs e )
{
 e.Effect = DragDropEffects.Move;
}

兩個DataGridView拖放也是一樣,只要把DragDrop、DragEnter移動到DataGridView2舊可以了,兩個DataGridView需要設定拖放True

 

Architecture 新手入门 June 25, 2008

Filed under: Uncategorized — meetme @ 3:11 pm
 

文件备份 May 9, 2008

Filed under: Uncategorized — meetme @ 9:14 pm
 

Borland C++ Builder VCL的字符串函数 May 5, 2008

Filed under: Uncategorized — meetme @ 11:39 am

原文地址:http://www.yesky.com/20020701/1618451_1.shtml

1. UpperCase
  将指定的AnsiString字符串转换为大写形式,函数原型如下:
  AnsiString __fastcall UpperCase(const AnsiString S);

  2. LowerCase
  将指定的AnsiString字符串转换为小写形式,函数原型如下:
  AnsiString __fastcall LowerCase(const AnsiString S);

  3. CompareStr
  比较两个AnsiString字符串,函数原型如下:
  int __fastcall CompareStr(const AnsiString S1, const AnsiString S2);

  4. CompareText
  比较两个AnsiString字符串,函数原型如下:
  int __fastcall CompareText(const AnsiString S1, const AnsiString S2);

  5. StrLen
  返回字符串的长度,函数原型如下:
  Cardinal __fastcall StrLen(const char * Str);

  6. StrEnd
  返回字符串结尾指针,函数原型如下:
  char * __fastcall StrEnd(const char * Str);

  7. StrMove
  从源字符串向目的字符串拷贝指定数目的字符,函数原型如下:
  char * __fastcall StrMove(char * Dest, const char * Source, Cardinal Count);

  8. StrCopy
  将源字符串拷贝到目的字符串中,函数原型如下:
  char * __fastcall StrCopy(char * Dest, const char * Source);

  9. StrECopy
  将源字符串拷贝到目的字符串中,并返回目的字符串结尾指针,函数原型如下:
  char * __fastcall StrECopy(char * Dest, const char * Source);

  10.StrLCopy
  将源字符串指定数目的字符拷贝到目的字符串中,并返回目的字符串指针,函数原型如下:
  char * __fastcall StrLCopy(char * Dest, const char * Source, Cardinal MaxLen);

  11.StrPCopy
  将AnsiString类型的源字符串拷贝到目的字符串中,并返回目的字符串指针,函数原型如下:
  char * __fastcall StrPCopy(char * Dest, const AnsiString Source);

  12.StrPLCopy
  将源字符串(AnsiString类型)指定数目的字符拷贝到目的字符串中,并返回目的字符串
指针,函数原型如下:
  char * __fastcall StrPLCopy(char * Dest, const AnsiString Source, Cardinal MaxLen);

  13.StrCat
  连接两个字符串,并返回目的字符串指针,函数原型如下:
  char * __fastcall StrCat(char * Dest, const char * Source);

  14.StrLCat
  将指定数目的源字符串连接到目的字符串,并返回目的字符串指针,函数原型如下:
  char * __fastcall StrLCat(char * Dest, const char * Source, Cardinal MaxLen);

  15.StrComp
  两个字符串相到比较,返回比较的结果,函数原型如下:
  int __fastcall StrComp(const char * Str1, const char * Str2);

  16.StrIComp
  两个字符串相互比较(不论大小写),返回比较的结果,函数原型如下:
  int __fastcall StrIComp(const char * Str1, const char * Str2);

  17.StrLComp
  对两个字符串指定数目的字符进行比较操作,函数原型如下:
  int __fastcall StrLComp(const char * Str1, const char * Str2, Cardinal MaxLen);

  18.StrScan
  在指定的字符串中寻找特定的字符,并返回字符串中第一个特定字符的指针,函数原型如下:
  char * __fastcall StrScan(const char * Str, char Chr);

  19.StrRScan
  在指定的字符串中寻找特定的字符,并返回字符串中最后一个特定字符的指针,函数原型如下:
  char * __fastcall StrRScan(const char * Str, char Chr);

  20.StrPos
  在Strl所指定的字符串中寻找Str2所指定的子字符串,并返回Str2在Str2中第一个子字符的指针,函数原型如下:
  char * __fastcall StrPos(const char * Str1, const char * Str2);

  21.StrUpper
  将字符串转换为大写形式,函数原型如下:
  char * __fastcall StrUpper(char * Str);

  22.StrLower
  将字符串转换为小写形式,函数原型如下:
  char * __fastcall StrLower(char * Str);

  23.StrPas
  将指定的字符串转换为AnsiString类型字符串对象,函数原型如下:
  AnsiString __fastcall StrPas(const char * Str);

  24.StrAlloc
  为字符串分配指定字节的内存,并返回内存指针,函数原型如下:
  char * __fastcall StrAlloc(Cardinal Size);

  25.StrBufSize
  返回*Str所指向内存的大小,函数原型如下:
  Cardinal __fastcall StrBufSize(const char * Str);

  26.StrNew
  在堆中为指定字符串分配空间,并将字符串拷贝到此空间中,函数原型如下:
  char * __fastcall StrNew(const char * Str);

 

Directory COPY April 29, 2008

Filed under: Uncategorized — meetme @ 12:50 pm

SHFILEOPSTRUCT   lpfile;  
  lpfile.hwnd       =   Handle;  
  lpfile.wFunc     =   FO_COPY;  
  lpfile.fFlags   =   FOF_FILESONLY   |FOF_MULTIDESTFILES;  
  lpfile.pFrom     =   “目标路径”;  
  lpfile.pTo         =   “源路径”;  
  lpfile.fFlags   =   FOF_MULTIDESTFILES;  
  lpfile.fAnyOperationsAborted=true;  
  SHFileOperation(&lpfile);  
 

 

发送邮件 April 25, 2008

Filed under: Uncategorized — meetme @ 9:26 pm

TNMSMTP *NMSMTP1 = new TNMSMTP(Application);

NMSMTP1->Host = “smtp.163.com”;     //SMTP主机名
NMSMTP1->UserID = “koji004″;      //用户名
NMSMTP1->PostMessageA->FromAddress = “koji004@163.com“;   //发信人地址
NMSMTP1->PostMessageA->ToAddress->Clear();     //收信人地址清空
NMSMTP1->PostMessageA->ToAddress->Text = “koji004@126.com“; //收信人地址
NMSMTP1->PostMessageA->ToCarbonCopy->Text = “85191213@qq.com“; //抄送地址
NMSMTP1->PostMessageA->ToBlindCarbonCopy->Text = “85191213@163.com“; //暗送地址
NMSMTP1->PostMessageA->Subject = “test message”;      //邮件标题
NMSMTP1->PostMessageA->Body->Add(“this is a test message!”); //邮件内容
NMSMTP1->PostMessageA->Attachments->Text = “C:\\cmd.txt”;      //邮件附件
NMSMTP1->PostMessageA->LocalProgram = “SendMail”;
NMSMTP1->Connect();
if (TRUE)
{
  AnsiString userName = Base64Encode(“/*这里写用户名*/”);  //将用户名编码
  AnsiString password = Base64Encode(“/*这里写密码*/”); //将密码编码
  NMSMTP1->Transaction(“auth login”);  //开始验证
  NMSMTP1->Transaction(userName);
  NMSMTP1->Transaction(password);
}
NMSMTP1->SendMail();
NMSMTP1->Disconnect();

delete NMSMTP1;
NMSMTP1=NULL;

 

如何修改桌面的存放路径??(将桌面放到D盘或E盘) April 22, 2008

Filed under: Uncategorized — meetme @ 4:38 am

如何修改桌面的存放路径??(将桌面放到D盘或E盘)

首先要在“开始”——“运行”内输入“regedit”打开注册表编辑器,然后要在“文件”下拉菜单中的“导出”功能备份好注册表,以防万一,接着在左侧窗口依次打开:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
在右侧窗口里,你看到的“名称”就代表那些特殊的文件夹,“数据”就是它们所对应的默认存储路径。修改默认的路径就可以让你的桌面文件夹移动了,下面是所有的.

下面介绍一下各个“名称”所代表的文件夹
名称 含义 默认路径
AppData 应用程序数据目录 C:\Documents and Settings\User name\Application Data
Cookies Cookies路径 C:\Documents and Settings\User name\Cookies
Desktop 桌面路径 C:\Documents and Settings\User name\桌面
Favorites 收藏夹 C:\Documents and Settings\User name\Favorites
NetHood NetHood路径 C:\Documents and Settings\User name\NetHood
Personal 我的文档 C:\Documents and Settings\User name\My Documents
PrintHood 打印 C:\Documents and Settings\User name\PrintHood
Recent 文档项路径 C:\Documents and Settings\User name\Recent
SendTo SendTo路径 C:\Documents and Settings\User name\SendTo
Start Menu 开始菜单路径 C:\Documents and Settings\User name\「开始」菜单
Templates 新建文件目录 C:\Documents and Settings\User name\Templates
Programs 程序菜单路径 C:\Documents and Settings\User name\「开始」菜单\程序
Startup 启动路径 C:\Documents and Settings\User name\「开始」菜单\程序\启动
History 网页历史记录 C:\Documents and Settings\ User name \Local Settings\History
My Pictures 图片收藏 C:\Documents and Settings\User name\My Documents\My Pictures
My Music 我的音乐 C:\Documents and Settings\User name\My Documents\My Music
My Video 我的视频 C:\Documents and Settings\User name\My Documents\My Videos
Cache Internet临时文件夹 C:\ Documents and Settings\User name \Temporary Internet Files
这些文件夹称为Shell文件夹
其中“User name”为当前用户的名称
了解了对应的文件夹,就可以根据自己的需要去更改对应的路径了。(千万不要在这儿改啊,那样可就瞎忙乎了,系统重起后它会恢复成原来的路径)
在同一层中你可以看到一个“User Shell Folders”的子键,即在HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ User Shell Folders
这里包括了用户定制的所有Shell文件夹的值项。只要通过修改“数据”,就可以改变它们的存储路径。双击需要修改的名称,在弹出的“编辑字符串”的“数值数据”里填上你要更改的完整路径,按下“确定”就完成了。如果没有你需要的,可以在右边窗口单击鼠标右键,选择“新建”菜单中的“字符串值”命令,对应上表,添加一个用于Shell文件夹的字符串值。
在上面的文件夹中,并没有outlook的通讯簿和邮件存放路径,它们分别在
通讯簿路径:
HKEY_CURRENT_USER\Software\Microsoft\WAB\WAB4\Wab File Name主键下,将“默认”键值改为你需要的路径。
邮件存放路径:
HKEY_CURRENT_USER\Identities\{8150FA22-A51C-4993-8A96-DC4B9A6B4C55}\Software\Microsoft\Outlook Express\5.0下,将 “Store Root”键值改为你需要的路径。
最后别忘了将修改好的这部分注册表导出保存,以便重装系统后可以直接导入而无须再次修改。
注意:修改了文件夹的路径值后,原有文件夹中的文件并不会移到新的文件夹中,这样做只改变了文件夹的指向。

 

http://www.bullzip.com/download.php April 15, 2008

Filed under: Uncategorized — meetme @ 11:07 am
Name Size Price License  
PDF Printer 3.7 MB Free Freeware Download | Donate
Access To MySQL 3.0 MB Free Freeware Download | Donate
Access To MSSQL 3.0 MB Free Freeware Download | Donate
Express Menu 0.2 MB Free Freeware Download | Donate
Copy File Name 1.8 MB Free Freeware Download | Donate
MD5 Calculator 0.4 MB Free Freeware Download | Donate
Patch Parent Paths 0.4 MB Free Freeware Download | Donate
Syntax Color 1.9 MB $10 Shareware Download | Buy
 

判断windows的Desktop及其它目录 March 2, 2008

Filed under: Uncategorized — meetme @ 3:31 pm

 使用API函数SHGetSpecialFoldershlobj.h里有SHGetSpecialFolder的原型声明。这个函数可以帮我们找到windowsDesktop目录、启动目录、我的文档目录等。     SHGetSpecialFolder需要三个参数。 第一个参数是HWND,它指定了所有者窗口:在调用这个函数时可能出现的对话框或消息框。第二个参数是一个整数id,决定哪个目录是待查找目录,它的取值可能是:

  • CSIDL_BITBUCKET 回收站
  • CSIDL_CONTROLS 控制面板
  • CSIDL_DESKTOP Windows 桌面desktop
  • CSIDL_DESKTOPDIRECTORY desktop的目录
  • CSIDL_DRIVES 我的电脑
  • CSIDL_FONTS 字体目录
  • CSIDL_NETHOOD 网上邻居
  • CSIDL_NETWORK 网上邻居virtual folder
  • CSIDL_PERSONAL 我的文档
  • CSIDL_PRINTERS 打印机
  • CSIDL_PROGRAMS 程序组
  • CSIDL_RECENT 大多数最近打开的文档列一
  • CSIDL_SENDTO “发送到菜单项
  • CSIDL_STARTMENU 任务条启动菜单项
  • CSIDL_STARTUP 启动目录
  • CSIDL_TEMPLATES 临时文档

    最后一个参数是pidl地址。SHGetSpecialFolderLocation把地址写到pidl     下面的代码演示了怎样使用SHGetSpecialFolderLocation

//--------------------------------------------------------------------- #define  NO_WIN32_LEAN_AND_MEAN// add First sentence   #include <ShlObj.hpp>   void __fastcall TForm1::Button1Click(TObject *Sender) {     LPITEMIDLIST  pidl;     LPMALLOC      pShellMalloc;     char          szDir[MAX_PATH];       if(SUCCEEDED(SHGetMalloc(&pShellMalloc)))     {         if(SUCCEEDED(SHGetSpecialFolderLocation(NULL,                                                 CSIDL_DESKTOPDIRECTORY,                                                 &pidl)))         {             // 如果成功返回true             if(SHGetPathFromIDList(pidl, szDir))             {                 Label1->Caption = szDir;             }               pShellMalloc->Free(pidl);         }           pShellMalloc->Release();     } }