这是一个为powerbuilder写的动态库,好像必须写成这种形式,否则会出现内存不可
访问的现象,但是开始时new出了一块内存,这里怎么释放啊???
LPVOID PASCAL getmtime(LPVOID pFileName)
{ CString str;
char *a,*buffer=new char[256];//****************************
a=(char *)pFileName;
if(file.Open(a,CFile::modeRead|CFile::modeCreate))
file.GetStatus(a,status);
else AfxMessageBox("error can't open file");
str.Format("%d年 %d月 %d日",status.m_mtime.GetYear(),status.m_mtime.GetMonth(),status.m_mtime.GetDay());
for(int i=0;i<str.GetLength();i++)
{buffer[i]=str.GetAt(i);
}
buffer[i]='\0';
//AfxMessageBox(buffer);
file.Close();
return buffer;//**************************************
}
访问的现象,但是开始时new出了一块内存,这里怎么释放啊???
LPVOID PASCAL getmtime(LPVOID pFileName)
{ CString str;
char *a,*buffer=new char[256];//****************************
a=(char *)pFileName;
if(file.Open(a,CFile::modeRead|CFile::modeCreate))
file.GetStatus(a,status);
else AfxMessageBox("error can't open file");
str.Format("%d年 %d月 %d日",status.m_mtime.GetYear(),status.m_mtime.GetMonth(),status.m_mtime.GetDay());
for(int i=0;i<str.GetLength();i++)
{buffer[i]=str.GetAt(i);
}
buffer[i]='\0';
//AfxMessageBox(buffer);
file.Close();
return buffer;//**************************************
}
解决方案 »
- DECLARE_MESSAGE_MAP()
- 【咨询】30~~35和35~~40两个年龄段的IT人员主要做什么啊?
- ADO+Access 如何得到未知表的列名及列的数目?
- 问个对话框的问题!
- 请问一下用过cximage类(cximage571_src)的兄弟!
- 关于文件遍历问题,在线等待!
- m_DateStart.Format("%Y-%m-%D")函数得不到“日”为哪般?
- 数据库是使用ACCESS,ADO连接,如果ACCESS是97或者2000,或者其他情况,怎么样编写代码能比较好的考虑到一切可能出现的数据库类型?
- 请问如何实现在对话框中显示当前时间啊?
- 搞不定了,请指点:用InstallShield for Microsoft Visual C++ 6对程序打包,
- 关于文件执行,100分
- 100分求3des加密算法代码!
访问不是这里的问题,而是PB中的问题,比如你在PB中调用是这样的
string str;str = space(256) //在这个地方分配空间str = getmtime("\\filename")这样应该是没有问题的,很多人调用DLL时候都会忘了space()