随笔2

1.窗口没有CControlUI*指针,因此可以通过获取一个容器等来代替;timer有窗口timer,Onnotify的timer

CControlUI*temp = static_cast<CControlUI*>(m_pmUI.FindControl(_T("MyContainer")));
  m_pmUI.SetTimer(temp,1,1000);

2.CStdString转换为string类型,WideCharToMultiByte

 函数功能:该函数映射一个unicode字符串到一个多字节字符串。

LPCSTR CStdString::GetChar()
{
 int nLen = WideCharToMultiByte(CP_ACP,0,m_pstr,GetLength(),NULL,0,NULL,NULL);

 if (m_pChar != NULL)
 {
  delete m_pChar;
  m_pChar = NULL;
 }
 m_pChar = new char[nLen+1];
 memset(m_pChar, 0, nLen+1);

 WideCharToMultiByte(CP_ACP,0,m_pstr,GetLength(),m_pChar,nLen,NULL,NULL);

 return m_pChar;
}

3.string转换为CStdString:CStdString a = string b.c_str();

4.把DLL的输出目录设置为和exe文件目录相同,这样在调试exe文件的时候就可以看到Dll的内部实现,然后进行调试!当然,前提是有DLL工程文件了。

5.调用DLL,只需要.lib,.dll和借口文件.h,在工程中添加.h和pragram comment就可以了

6.vcproj是工程文件,sln是解决方案文件。
  一个解决方案里面可以包含多个工程。

7.int snprintf(char *str, size_t size, const char *format, ...); 将可变个参数(...)按照format格式化成字符串,然后将其复制到str中

8.创建注册表子键:RegCreateKeyEx(hRegKey, strRegEntry.c_str(), 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,&hKey, NULL );

9.CopyFile;DeleteFile。

10.FindFirstFile:该函数到一个文件夹(包括子文件夹)去搜索指定文件;FindNextFile;FindClose

11.pair<string, RealTimeMsg> pr(strName, RealMsg);
    map m_MsgMap.insert(pr);

12.char *const p(const 修饰的是p):只能对“某个固定的位置” 进 行读写操作

13. strnicmp 功 能: 比较字符串str1和str2的前n个字符串字典序的大小,但是不区分字母大小写。

14.WM_NCLBUTTONDBLCLK、WM_LBUTTONDBLCLK的不同,WM_NCLBUTTONDBLCLK非客户区双击,如双击标题栏

15.lstrcat:unicode字符串连接

16.读取一行:

string temp(szTemp);
 string::size_type index = temp.find_first_of('\r');
 string src = temp.substr(index+1, temp.length()-index-1);
 if(src.length() <= 0 || (src.length() == 1 && src[0] == '\r'))
  return false;

17.返回子进程的句柄:

 

SHELLEXECUTEINFO shei = {0} ;
  shei.cbSize = sizeof(shei) ;
  shei.hwnd = NULL ;
  shei.lpVerb = _T("open") ;
  shei.lpFile       = _T("..\\bin\\Guide.exe") ;
  shei.lpDirectory  = NULL ;
  shei.nShow        = SW_SHOWNORMAL ;
  shei.lpParameters = NULL ;
  shei.fMask        = SEE_MASK_NOCLOSEPROCESS;
  
  ::ShellExecuteEx(&shei);
  HANDLE hWnd = shei.hProcess;

 

  DWORD dw = WaitForSingleObject(hWnd, INFINITE);//这一功能是无限止等待子进程退出

 

posted @ 2012-04-05 18:51  tianyuanmuge  阅读(215)  评论(0)    收藏  举报