|
The DeleteFile function deletes an existing file.
BOOL DeleteFile(
LPCTSTR lpFileName
);
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
If you want to be more portable across various platforms:
int unlink(const char *filename)
-- modified at 2:23 Monday 30th July, 2007
Roberto
|
|
|
|
|
|
Hello everyone,
I am wondering how to remove a non-empty directory on Windows? I find that function RemoveDirectory works only for empty directory.
thanks in advance,
George
|
|
|
|
|
A quick search give me the below link. I have not tested/used.
http://www.codeproject.com/cpp/Clean_Workspace.asp
|
|
|
|
|
Good reference, thanks mandanani!
Since I need to use API DeleteFile, I am wondering how to pass path name string which is encoded as multi-byte character or wide character?
In the article, it is an MFC project so CString is used, but I am not using MFC based Windows project, and I can not use CString data type.
Any ideas?
regards,
George
|
|
|
|
|
To delete a non-empty directory I usually use a loop with FindFirstFile()/FindNextFile().
If you want to delete a whole subtree, you can make a littel recursive function using the above calls: it is very simple. Pay attention to the read-only files: you should change the read-only attribute (if you can) before removing them.
Hope this helps.
Roberto
|
|
|
|
|
Thanks Roberto,
For API DeleteFile, I am wondering how to pass path name string which is encoded as multi-byte character or wide character?
regards,
George
|
|
|
|
|
try SHFileOperation(..) shell API
|
|
|
|
|
Hi nitinmx,
I need to run program on both Windows desktop and Windows CE, I am wondering whether SHFileOperation could be supported on Windows CE?
regards,
George
|
|
|
|
|
As most people don't program for windows CE, you could always look at the help file to see if it supported yourself. Or try using it and fail?
Iain.
|
|
|
|
|
Hi,
I have many string values . I am displaying them on GDI using the
TEXTOUT() method . but my problem is that I want to SCroll them
on the GDI .also I am displaying bimap usig bitblt(). I also wants
to scroll many bitmpas on the GDI
Trioum
|
|
|
|
|
Then you have to save your relative position of your elements and then update them with the position of your CScrollview in every OnDraw. I made it like this:
void CMyView::OnInitialUpdate()
{ CScrollView::OnInitialUpdate();
CSize sizeTotal;
sizeTotal.cx = 950; sizeTotal.cy = 1400;
SetScrollSizes(MM_TEXT, sizeTotal);
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
extern CMyDoc* m_pDoc;
m_pDoc = GetDocument ();
pDoc->UpdateDescription ();
m_hCursor=AfxGetApp()->LoadStandardCursor(IDC_ARROW);
return;
}
void CMyView::OnDraw(CDC* pDC)
{ PlaceElement ();
return;
}
void CMyView::PlaceElement ()
{ CMyDoc* pDoc = GetDocument ();
ASSERT_VALID (pDoc);
CClientDC dc(this);
CDC dcNormMem;
dcNormMem.CreateCompatibleDC (&dc);
CDC dcSelMem;
dcSelMem.CreateCompatibleDC (&dc);
CString szTempText = "";
CPoint cpTempPos, cpTempTextPos, cpScrollPoint = GetScrollPosition ();
CBitmap bmNormIn, bmNormOut, bmNormReg, bmSel;
BITMAP bmNormTemp, bmSelTemp;
for (int nIn = 0; nIn < pDoc->m_cMyListSet.GetCount (); nIn++)
{ if (!pDoc->m_cMyListSet[nIn].m_bInSel)
{ if (bmNormIn.m_hObject != NULL)
bmNormIn.DeleteObject ();
bmNormIn.LoadBitmap (IDB_NORMIN);
bmNormIn.GetObject(sizeof(bmNormTemp), &bmNormTemp);
dcNormMem.SelectObject(&bmNormIn);
cpTempPos.x = pDoc->m_cMyListSet[nIn].m_cpInCoord.x - cpScrollPoint.x;
cpTempPos.y = pDoc->m_cMyListSet[nIn].m_cpInCoord.y - cpScrollPoint.y;
dc.BitBlt(cpTempPos.x, cpTempPos.y, bmNormTemp.bmWidth,
bmNormTemp.bmHeight, &dcNormMem, 0, 0, SRCCOPY);
szTempText = pDoc->m_cmlInputSet[nIn].m_szInName;
dc.SetTextColor(RGB(0,0,0));
dc.TextOut (cpTempPos.x, cpTempPos.y + SIGHEIGHT + 1, szTempText);
}
}
}
With these I put one Bitmap and a label with its name below for every element I have , and when I scroll the View surface its position scrolls as well.
Hope it helps
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
actually i donot want to scroll image and text by picking from list by by one .I want to scroll them like the news tickers in News Channel
can you help.
Trioum
|
|
|
|
|
????
Explain it a bit. I don't know what you mean
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hello Gurus...
Using pDC->GetClipBox(&rect), i Will get clip region of pDC(my CDC*).
But
m_DC is my another DC, and i want to assign the clip region of pDC to m_DC.
How to assign?????????????
thanks in advance
|
|
|
|
|
Try this ..
// get current clipping boundary
RECT rect;
pDC->GetClipBox( &rect );
// Selects the current clipping region for other dc
CRgn rgn;
rgn.CreateRectRgnIndirect( &rect );
m_DC.SelectClipRgn( &rgn );
... hope it helps
|
|
|
|
|
Thanks "csc"
its exactly does what i expect...
|
|
|
|
|
hello
please help to solve this problem
when i coonect vc++ to mysql
and use this code to fetch data from mysql
mysql_query(myDB,"select password from login where user= \'" + user + "\'");
i = mysql_query(myDB,"select * from login");
res=mysql_store_result(myDB);
row = mysql_fetch_row(res);
MessageBox(row[0]);
but when i use debugger at this line row = mysql_fetch_row(res);
an unhandled exception myapp.exe(libmysql.dll) access violation appears in message box and when i click ok then in output window of vc++ following messages appears :
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\DOGRA\company\libmySQL.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wsock32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ws2_32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ws2help.dll', no matching symbolic information found.
Loaded symbols for 'C:\WINDOWS\system32\MFC42D.DLL'
Loaded symbols for 'C:\WINDOWS\system32\MSVCRTD.DLL'
Loaded symbols for 'C:\WINDOWS\system32\MFCO42D.DLL'
Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\lpk.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\usp10.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\uxtheme.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\MSCTFIME.IME', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
Warning: no listbox item selected.
Loaded 'C:\WINDOWS\system32\mswsock.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\dnsapi.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\winrnr.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wldap32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rasadhlp.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\hnetcfg.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wshtcpip.dll', no matching symbolic information found.
First-chance exception in company.exe (LIBMYSQL.DLL): 0xC0000005: Access Violation.
The program 'C:\DOGRA\company\Debug\company.exe' has exited with code 0 (0x0).
now please help me to solve this problem
hi
|
|
|
|
|
Please stop reposting. Be patient. If you keep on reposting it will not only annoy people out here but also prevent them from answering to you query. please refrainf from this habit.
In the meantime please debug the Application Step by Step. you might hit upon something.
There are only two kinds of people who are really fascinating-people who know absolutely everything, and people who know absolutely nothing.
Oscar Wilde (1854-1900)
Regards...
Shouvik
|
|
|
|
|
Hi all,
Recently, I have encountered a "Out of memory" issue, but I found that system still has enough memory.
Here are some information about this issue.
I tried to new an array like below codes
try<br />
{<br />
<br />
<br />
unsigned long* mImage = new unsigned long[67108864];
<br />
}<br />
catch( CMemoryException* pEX)<br />
{<br />
CString cstmp;<br />
CString csOut;<br />
MEMORYSTATUS stat; <br />
GlobalMemoryStatus (&stat);<br />
<br />
cstmp.Format("The MemoryStatus structure is %ld bytes long.\n",stat.dwLength);<br />
csOut+=cstmp;<br />
cstmp.Format("It should be %d.\n", sizeof (stat));<br />
csOut+=cstmp;<br />
cstmp.Format("%ld percent of memory is in use.\n",stat.dwMemoryLoad);<br />
csOut+=cstmp;<br />
cstmp.Format("There are %7d total Kbytes of physical memory.\n",stat.dwTotalPhys/1024);<br />
csOut+=cstmp;<br />
cstmp.Format("There are %7d free Kbytes of physical memory.\n",stat.dwAvailPhys/1024);<br />
csOut+=cstmp;<br />
cstmp.Format("There are %7d total Kbytes of paging file.\n",stat.dwTotalPageFile/1024);<br />
csOut+=cstmp;<br />
cstmp.Format("There are %7d free Kbytes of paging file.\n",stat.dwAvailPageFile/1024);<br />
csOut+=cstmp;<br />
cstmp.Format("There are %7x total Kbytes of virtual memory.\n",stat.dwTotalVirtual/1024);<br />
csOut+=cstmp;<br />
cstmp.Format("There are %7x free Kbytes of virtual memory.\n",stat.dwAvailVirtual/1024);<br />
csOut+=cstmp;<br />
pEx->Delete();<br />
AfxMessageBox(csOut);<br />
}
System will throw an exception( CMemoryException ) and I tried to print out the status of memory.
The following list is the output result.
The MemoryStatus structure is 32 bytes long.
It should be 32.
36 percent of memory is in use.
There are 2096100 total Kbytes of physical memory.
There are 1321288 free Kbytes of physical memory.
There are 4041780 total Kbytes of paging file.
There are 3615048 free Kbytes of paging file.
There are 1fff80 total Kbytes of virtual memory.
There are 70e94 free Kbytes of virtual memory.
I think that system still has about 1.3GB memory but I just want to allocate 256MB. Why does system throw a memory exception and tell me an error message "out of memory"?
Does any one can tell how I can solve this problem?? Any suggestions are welcome. Thanks a lot.
Regards,
Pogo Lin
|
|
|
|
|
Where does it get the Out of Memory error at?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
When I tried to allocate memory it will throw CMemoryException.
The code I posted is a function. It will be called many times. But sometimes it will throw CMemoryException.
So I tried to print out the using status of memory and hope to find out the question.
Any body have any ideas how to get more information for using memory?
Regards,
Pogo Lin
|
|
|
|
|
The system may have "enough" memory left but not enough to allocate 256MB of contiguous memory.
Steve
|
|
|
|
|
Recently, I was confused with the problem of displaying text. Supposed I created a single document application named "Text", and the CTextView inherited from CView. The map mode is MM_LOMETRIC.
There is the following code segment:
INT_PTR nRet = -1;
CFontDialog fontDialog;
nRet = fontDialog.DoModal();
CString str("There is a will, there is a way!");
if(nRet == IDOK)
{
LOGFONT lf;
fontDialog.GetCurrentFont(&lf);
CFont font;
font.CreateFontIndirect(&lf);
CDC *pDC = GetDC();
OnPrepareDC(pDC);
CFont *pOldFont;
pOldFont = pDC->SelectObject(&font);
pDC->TextOut(500, -500, str);
}
Why the text is so small, even I select the largest size?
Help!
|
|
|
|
|