Hui 的个人资料逆风沉沦日志列表 工具 帮助

日志


2007/4/30

test

2007/2/25

test

test
2007/1/8

test

怎么由dll文件生成对应的lib文件

我有一个DLL及对应的头文件,如何生成VC所要的LIB文件。 
 
1. dumpibn   /exports   Your.dll   >   Your.def  
  edit   Your.def,Let   it   become   standard   def   file  
  (  
  like:  
   
  EXPORTS:  
    abc  
    def  
   
  )  
   
  lib   /def:Your.def   /out:Your.lib  
 

2. 有了头文件,说明你已经知道导出函数。  
  可以这样:使用楼上兄弟提到的工具查到对应函数导出函数写一个DEF文件:  
  LIBRARY   youdll.dll  
  EXPORTS  
          Func1@0                             @2  
   
  然后  
  lib   /MACHINE:IX86   /DEF:yourLIB.DEF  
2007/1/5

test

test

高效拆分字符串

 

inline int stringSplit1(const char* lpszToSplit,char delemit, const char* lpszStartArray[],int nSizeArray[],int nArraySize)
{
        if(!lpszToSplit)
                return 0;
        int             nPart   = 0;   
        int             nSize   = 0;
        bool    bNew    = true;
        for(;*lpszToSplit;lpszToSplit++)
        {      
                if(bNew)
                {              
                        nPart++;
                        if(nPart > nArraySize)
                                break;
                       
                        bNew = false;
                        lpszStartArray[nPart-1] = lpszToSplit;
                        nSize = 0;
                }
               
                if(*lpszToSplit==delemit)
                {      
                        bNew =true;            
                        nSizeArray[nPart-1] = nSize;
                }
                else
                {
                        nSize++;
                }
        }
        if(!bNew)
                nSizeArray[nPart-1] = nSize;
        return nPart > nArraySize ? -1 : nPart ;
}
2006/12/19

test

写了一个分割字符串的函数

void stringSplit(const std::string& strToSplit,const std::string& strDelimit, std::vector<std::string>& vecStringOutput)
{
        vecStringOutput.clear();
        std::string::size_type begin,end;
        begin = strToSplit.find_first_not_of(strDelimit);
        while(begin!=std::string::npos)
        {
                end = strToSplit.find_first_of(strDelimit,begin);
                vecStringOutput.push_back(strToSplit.substr(begin,end-begin));
                begin = strToSplit.find_first_not_of(strDelimit,end);
        }
}
 
void stringSplit(const std::string& strToSplit,char delimit, std::vector<std::string>& vecStringOutput)
{
        vecStringOutput.clear();
        std::string::size_type begin=0,end=0,length=strToSplit.length();
        while(begin<length && end!=std::string::npos)
        {
                end = strToSplit.find(delimit,begin);
                vecStringOutput.push_back(strToSplit.substr(begin,end-begin));
                begin = end + 1;
        }
}
2006/11/24

test

test

ifstream, ofstream 有时打开带中文路径的文件会失败

似乎跟文件系统是ntfs还是fat有关, 解决的办法如下:
 
1. 使用c函数
setlocale(LC_ALL,"Chinese-simplified");
 
2. 使用stl
std::locale::global(std::locale(""));
 
2006/11/15

test

test
2006/10/20

TEST

TEST
2006/9/26

test

CHyperLink动态创建时存在问题

CHyperLink动态创建时存在问题
 CHyperLink是网上流传很广的一个超链接类, 但是我在使用过程中发现, 动态创建该类时会出现问题, 经跟踪调试发现问题出在CHyperLink类的PreSubclassWindow中. 先看看代码:

void CHyperLink::PreSubclassWindow()
{     
 // If the URL string is empty try to set it to the window text
    if (m_strURL.IsEmpty())
        GetWindowText(m_strURL);

    // Check that the window text isn't empty.
 // If it is, set it as URL string.
    CString strWndText;
    GetWindowText(strWndText);
    if (strWndText.IsEmpty()) {
  // Set the URL string as the window text
        ASSERT(!m_strURL.IsEmpty());    // window text and URL both NULL!
  CStatic::SetWindowText(m_strURL);
    }

    // Get the current window font 
    CFont* pFont = GetFont(); 
 
 if (pFont != NULL) {
  LOGFONT lf;
  pFont->GetLogFont(&lf);
  lf.lfUnderline = BITSET(m_dwStyle, StyleUnderline);
  if (m_Font.CreateFontIndirect(&lf))
   CStatic::SetFont(&m_Font);   
  // Adjust window size to fit URL if necessary
  AdjustWindow();
 }
 else {  
  // if GetFont() returns NULL then probably the static
  // control is not of a text type: it's better to set
  // auto-resizing off
  CLEARBITS(m_dwStyle,StyleAutoSize);
 }
 
 if (!BITSET(m_dwStyle,StyleNoHandCursor))
  SetDefaultCursor();      // Try to load an "hand" cursor

    // Create the tooltip
    CRect rect;
    GetClientRect(rect);
    m_ToolTip.Create(this); 

    m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID);

    CStatic::PreSubclassWindow();
}

通常我们动态创建该类都是这样写的:
CHyperLink *pHyperLink = new CHyperLink;
pHyperLink->Create("hello",WS_CHILD|WS_VISIBLE,CRect(0,0,100,100),this);

很少有人会在调用Create之前先调用SetURL, 这样 ASSERT(!m_strURL.IsEmpty())这句会断言失败, 为了避免这种情况, 必须记得在Create之前先调用SetURL, 给m_strURL赋上值, 或者将这里改为:
if(!m_strURL.IsEmpty())
    CStatic::SetWindowText(m_strURL);

另一个严重的问题是m_ToolTip.Create(this)会引起崩溃, 解决的方法是将以下几句
    CRect rect;
    GetClientRect(rect);
    m_ToolTip.Create(this); 
    m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID);
移动到OnCreate中去.

CHyperLink类见如下链接:
http://www.codeguru.com/Cpp/controls/controls/hyperlinkcontrols/article.php/c2185#more

2006/9/1

test

2006/8/15

test

test
2006/7/21

test

2006/7/19

test

2006/6/13

test

test