如果你在打开对话框时弹出 "The ActiveX control "Grid Control" could not be instantiated because it requires a design-time license"这个对话框时,在VC安装盘中找到vb6controls.reg,双击导入注册表就OK了,没有这个文件的可以COPY下面的代码另存为*.reg,导入注册表就行了
REGEDIT
HKEY_CLASSES_ROOT\Licenses = Licensing: Copying the keys may be a violation of established copyrights.
// Masked Edit Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\BC96F860-9928-11cf-8AFA-00AA00C00905 = mmimfflflmqmlfffrlnmofhfkgrlmmfmqkqj
// Chart Control 6.0 (OLEDB) license key
HKEY_CLASSES_ROOT\Licenses\12B142A4-BD51-11d1-8C08-0000F8754DA1 = aadhgafabafajhchnbchehfambfbbachmfmb
// Common Dialog Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\4D553650-6ABE-11cf-8ADB-00AA00C00905 = gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj
// ADO Data Control 6.0 (OLEDB) license key
HKEY_CLASSES_ROOT\Licenses\C4145310-469C-11d1-B182-00A0C922E820 = konhqhioohihphkouimonhqhvnwiqhhhnjti
// Common Controls-3 6.0 license key
HKEY_CLASSES_ROOT\Licenses\38911DA0-E448-11D0-84A3-00DD01104159 = mcpckchcdchjcjcclidcgcgchdqdcjhcojpd
// Windows Common Controls-2 5.0 (SP2) license key
HKEY_CLASSES_ROOT\Licenses\9E799BF1-8817-11cf-958F-0020AFC28C3B = uqpqnqkjujkjjjjqwktjrjkjtkupsjnjtoun
// Windows Common Controls license key
HKEY_CLASSES_ROOT\Licenses\57CBF9E0-6AA7-11cf-8ADB-00AA00C00905 = aahakhchghkhfhaamghhbhbhkbpgfhahlfle
// Data Bound Grid Control 5.0(SP3) license key
HKEY_CLASSES_ROOT\Licenses\556C75F1-EFBC-11CF-B9F3-00A0247033C4 = xybiedobrqsprbijaegcbislrsiucfjdhisl
// Data Bound List Controls 6.0 license key
HKEY_CLASSES_ROOT\Licenses\096EFC40-6ABF-11cf-850C-08002B30345D = knsgigmnmngnmnigthmgpninrmumhgkgrlrk
// Internet Transfer Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\78E1BDD1-9941-11cf-9756-00AA00C00908 = yjrjvqkjlqqjnqkjvprqsjnjvkuknjpjtoun
// Multimedia Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\B1EFCCF0-6AC1-11cf-8ADB-00AA00C00905 = qqkjvqpqmqjjpqjjvpqqkqmqvkypoqjquoun
// Chart Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\7C35CA30-D112-11cf-8E72-00A0C90F26F8 = whmhmhohmhiorhkouimhihihwiwinhlosmsl
// Windows Common Controls-2 6.0 license key
HKEY_CLASSES_ROOT\Licenses\4F86BADF-9F77-11d1-B1B7-0000F8753F5D = iplpwpnippopupiivjrioppisjsjlpiiokuj
// Windows Common Controls 6.0 license key
HKEY_CLASSES_ROOT\Licenses\ED4B87C4-9F76-11d1-8BF7-0000F8754DA1 = knlggnmntgggrninthpgmnngrhqhnnjnslsh
// Comm Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\4250E830-6AC2-11cf-8ADB-00AA00C00905 = kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun
// DataGrid Control 6.0 (OLEDB) license key
HKEY_CLASSES_ROOT\Licenses\CDE57A55-8B86-11D0-b3C6-00A0C90AEA82 = ekpkhddkjkekpdjkqemkfkldoeoefkfdjfqe
// DataList Control 6.0 (OLEDB) license key
HKEY_CLASSES_ROOT\Licenses\A133F000-CCB0-11d0-A316-00AA00688B10 = cibbcimbpihbbbbbnhdbeidiocmcbbdbgdoc
// DBWin license key
HKEY_CLASSES_ROOT\Licenses\D015B071-D2ED-11d0-A31A-00AA00688B10 = gjdcfjpcmjicjcdcoihcechjlioiccechepd
// MSDBRPT license key
HKEY_CLASSES_ROOT\Licenses\9DF1A470-BA8E-11D0-849C-00A0C90DC8A9 = cchcqjejhcgcqcfjpdfcdjkckiqikchcojpd
// FlexGrid Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\72E67120-5959-11cf-91F6-C2863C385E30 = ibcbbbebqbdbciebmcobmbhifcmciibblgmf
// MAPI Controls 6.0 license key
HKEY_CLASSES_ROOT\Licenses\899B3E80-6AC6-11cf-8ADB-00AA00C00905 = wjsjjjlqmjpjrjjjvpqqkqmqukypoqjquoun
// MSRDO 2.0 license key
HKEY_CLASSES_ROOT\Licenses\B1692F60-23B0-11D0-8E95-00A0C90F26F8 = mjjjccncgjijrcfjpdfjfcejpdkdkcgjojpd
// RemoteData Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\43478d75-78e0-11cf-8e78-00a0d100038e = imshohohphlmnhimuinmphmmuiminhlmsmsl
// Windowless Controls 6.0 license key
HKEY_CLASSES_ROOT\Licenses\80E80EF0-DBBE-11D0-BCE2-00A0C90DCA10 = qijimitpmpnpxplpvjnikpkpqoxjmpkpoivj
// PictureClip Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\6FB38640-6AC7-11cf-8ADB-00AA00C00905 = gdjkokgdldikhdddpjkkekgknesjikdkoioh
// Rich TextBox Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\DC4D7920-6AC8-11cf-8ADB-00AA00C00905 = iokouhloohrojhhhtnooiokomiwnmohosmsl
// Sheridan Tab Control license key
HKEY_CLASSES_ROOT\Licenses\190B7910-992A-11cf-8AFA-00AA00C00905 = gclclcejjcmjdcccoikjlcecoioijjcjnhng
// SysInfo Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\E32E2733-1BC5-11d0-B8C3-00A0C90DCA10 = kmhfimlflmmfpffmsgfmhmimngtghmoflhsg
// Winsock Control 6.0 license key
HKEY_CLASSES_ROOT\Licenses\2c49f800-c2dd-11cf-9ad6-0080c7e7b78d = mlrljgrlhltlngjlthrligklpkrhllglqlrk
最近把以前的代码升级到VS2008下,运行常出现堆栈溢出,莫名其秒的堆释放崩溃.
搞得人都快疯了,后来发现是在代码中使用了对齐的原因,为了进一步确定问题,新建一个工程,只引用tinyxml.h并定义一个结构采用#pragma pack(push,1)对齐,一运行就会出现崩溃......
而采用
#pragma pack(1)
#pragma pack()
则一切正常
我new CSocketThread类,然后在退出时delete this;
VC2005 Debug模式运行时报HEAP Corruption DETECTED。。。。。错误,就在delete this那里,从新运行程序并在new的地方和delete this那里下断点,发现在DEBUG模式下在堆中new对象时C++编译器会在new到的指针前后各放4字节的0xFD,在delete时检查前后的值是否为0xFD,如果不为0xFD则出现内存溢出。有问题就跟踪到C++的源码中去,你会发现很多平常调试时学不到的东西.
虽然发现这个“密秘”了,但是我的问题还是没有解决,再跟踪,我发现在new对象时,new完(也就是构造函数执行完了),我看了一下new返回的指针前后的内存数据,尾部的前面3个0xFD被清0了,OK,再重新运行,跟入到构造函数中去,发现在对一个成员变量进行清0时,会碰到那3个值,很奇怪,在内部对成员变量进行赋值操作会改到内存以外的值。。。郁闷中。。。百思不得其解,后来sizeof了类的大小,发现不是默认的4字节对齐,在类中,有几个成员变量,都是DWORD的,要不就是指针,只有一个BYTE成员,就出在这个BYTE成员上,找了老长时间的问题终于找到了,总算安心了。睡了,有写的了再写。。。
环境:Visual Studio Team Suite 2005
类型:Debug
以下是简化代码,出现让人摸不着头脑的Run-Time Check Failure,具体原因还在研究中,有结果会公布上来,N久没写博客了,太忙了。。。
代码1
#include 'stdafx.h'
void malice()
...{
printf('Hey,you're been attacked.\n');
}
![]()
void foo()
...{
int *ret;
ret=(int*)&ret+2;
(*ret)=(int)malice;
}
![]()
int _tmain(int argc, _TCHAR* argv[])
...{
foo();
return 0;
}
运行后出现:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
代码2
#include 'stdafx.h'
void foo()
...{
int var[2];
var[2] = 0;
}
![]()
int _tmain(int argc, _TCHAR* argv[])
...{
foo();
return 0;
}
运行后出现:
Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted.
![]()
#include 'stdafx.h'
#include <iostream>
using namespace std;
![]()
int a,b;
int _tmain(int argc, _TCHAR* argv[])
...{
int c;
cout<<a<<'\n';
cout<<b<<'\n';
cout<<c<<'\n';
return 0;
}
运行后出现:
Run-Time Check Failure #3 - The variable 'c' is being used without being defined.
The following is an example of rich edit2.0 based on the default SD rich edit project.
Please email me for source code.
1.revise PreCreateWindows
BOOL CRich20DocViewView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
// return CRichEditView::PreCreateWindow(cs);
m_strClass="RichEdit20A";
BOOL nR=CRichEditView::PreCreateWindow(cs);
LoadLibraryA("RICHED20.DLL");
return nR;
}
2. revise OnDestory
void CRich20DocViewView::OnDestroy()
{
// Deactivate the item on destruction; this is important
// when a splitter view is being used.
// CRichEditView::OnDestroy();
COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
{
pActiveItem->Deactivate();
ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
}
CRichEditView::OnDestroy();
}
3. Enable auto URL detect in OnInitialUpdate()
long lENM=GetRichEditCtrl().GetEventMask();
lENM|=ENM_LINK;
GetRichEditCtrl().SetEventMask(lENM);
BOOL bEnable=1;
::SendMessage(m_hWnd,EM_AUTOURLDETECT,bEnable,0);
4. URL left-button_dwon open with notify message
ON_NOTIFY_REFLECT_EX(EN_LINK, OnLink )
afx_msg void OnLink( NMHDR* in_pNotifyHeader, LRESULT* out_pResult );
void CRich20DocViewView::OnLink( NMHDR* in_pNotifyHeader, LRESULT* out_pResult )
{
ENLINK * pLink=(ENLINK*) in_pNotifyHeader;
if(pLink->msg==WM_LBUTTONDOWN)
{
GetRichEditCtrl().SetSel(pLink->chrg);
CString str=GetRichEditCtrl().GetSelText();
ShellExecute( this->GetSafeHwnd(), _T( "open" ), str, NULL, NULL, SW_SHOWNORMAL ) ;
}
}
5. To print correctly, revise OnPrint. Without the following, there might be a non-stop print with blank pages)
void CRich20DocViewView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
ASSERT_VALID(this);
ASSERT_VALID(pDC);
ASSERT(pInfo != NULL);
ASSERT(pInfo->m_bContinuePrinting);
UINT nPage = pInfo->m_nCurPage;
ASSERT(nPage <= (UINT)m_aPageStart.GetSize());
long nIndex = (long) m_aPageStart[nPage-1];
// print as much as possible in the current page.
nIndex = PrintPage(pDC, nIndex, 0xFFFFFFFF);
//nIndex got above hasn't take "return" into account
//The following codes add nIndex when there are any new lines
int nLength=GetTextLength();
CString strRich;
GetRichEditCtrl().GetWindowText(strRich);
int nS=0;
while(nS!=-1)
{
nS=strRich.Find("\r\n",nS);
if(nS!=-1)
{
nLength--;
nS++;
}
}
//END adding nIndex
//other error that might cause non-stop print
if(m_nIndex==nIndex)
nLength-=10000;
m_nIndex=nIndex;
//end other erro
if (nIndex >= nLength)//GetTextLength()
{
TRACE0("End of Document\n");
pInfo->SetMaxPage(nPage);
}
// update pagination information for page just printed
if (nPage == (UINT)m_aPageStart.GetSize())
{
if (nIndex < nLength)//GetTextLength()
m_aPageStart.Add(nIndex);
}
else
{
ASSERT(nPage+1 <= (UINT)m_aPageStart.GetSize());
ASSERT(nIndex == (long)m_aPageStart[nPage+1-1]);
}
// CRichEditView::OnPrint(pDC, pInfo);
}





printf(
}