|
Can't you just write a SmartMoveFile function or something that scans for those characters first? You can get a nice list of invalid characters by putting a ':' in a filename in Explorer.
Or maybe I'm missing something?
Mike
|
|
|
|
|
|
Rename a file or directory.
Renames the file or directory specified by oldname to newname.
If oldname and newname specify different paths the file is moved.
Parameters.
oldname
Path and name of the file to be renamed or moved. This file must exist and we must have write access to it.
newname
New path and name for the file. This filename must not be the same of an existing one.
Return Value.
If the file is succesfully renamed/moved a 0 value is returned.
On error a non-zero value is returned and the errno variable is set to the corresponding error code that can be printed using perror.
Portability.
Defined in ANSI-C.
Some systems do not allow to move directories.
Example.
/* rename example */
#include <stdio.h>
int main ()
{
int result;
char oldname[] ="oldname.txt";
char newname[] ="newname.txt";
result= rename( oldname , newname );
if (result != 0 )
perror( "Error renaming file" );
return 0;
}
If the file oldname.txt existed before the execution and we meet the permission requirements to call this function the file will be renamed to newname.txt, otherwise a message similar to this will be written to stderr:
Error renaming file: Pemission denied
Errors
Rename will fail and neither of the argument files will be affected if: [ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX} characters.
[ENOENT] A component of the from path does not exist, or a path prefix of to does not exist.
[EACCES] A component of either path prefix denies search permission.
[EACCES] The requested link requires writing in a directory with a mode that denies write permission.
[EPERM] The directory containing from is marked sticky, and neither the containing directory nor from are owned by the effective user ID.
[EPERM] The to file exists, the directory containing to is marked sticky, and neither the containing directory nor to are owned by the effective user ID.
[ELOOP] Too many symbolic links were encountered in translating either pathname.
[ENOTDIR] A component of either path prefix is not a directory.
[ENOTDIR] from is a directory, but to is not a directory.
[EISDIR] to is a directory, but from is not a directory.
[EXDEV] The link named by to and the file named by from are on different logical devices (file systems). Note that this error code will not be returned if the implementation permits cross-device links.
[ENOSPC] The directory in which the entry for the new name is being placed cannot be extended because there is no space left on the file system containing the directory.
[EDQUOT] The directory in which the entry for the new name is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted.
[EIO] An I/O error occurred while making or updating a directory entry.
[EROFS] The requested link requires writing in a directory on a read-only file system.
[EFAULT] Path points outside the process's allocated address space.
[EINVAL] From is a parent directory of to, or an attempt is made to rename '.' or '..'.
[ENOTEMPTY] To is a directory and is not empty.
|
|
|
|
|
I have always believed that the best way to avoid an error is to try to catch it in the first place. to that end, I would suggest validating the paths passed to the MoveFile(...) before calling it.
The PathGetCharType(...) function is a great place to start when you need to validate the characters in a path.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hey guys,
Im wondering if anybody could help me with a link or some ideas on how to acknowledge whether the user successfully traces a letter or symbol on the screen using the mouse in OpenGL.
Just to clarify, say my program put a large 'S' on the screen. The program would wait until the mouse first entered the 'S' and then monitor the cursor movements, making sure it went all the way around the letter and had a way of recording how many times it went out of the lines.
I can handle the little extras like counting the mistakes but the general idea of following a letter on the screen confuses me. Thanks for your time!
~Matt
|
|
|
|
|
Hey all-
Just wondering if there is a way to make a CListCtrl *always* show a vertical scrollbar. I've googled and MSDN'd this thing to death. No one has been able to help other than to advise me to change to a ListBox.
Would be nice to disable/enable the horizontal at will, but not as crucial for the aesthetics of this app. I can just alter the col widths as necessary.
Thanks for reading!
-Ryan
|
|
|
|
|
if you want to disable scrollbars did you see EnableScrollBar*
|
|
|
|
|
Yes, I tried it, but it didnt seem to have any effect for the CListCtrl. Does anyone know of a tried and true method for this? MSDN, google, etc, doesnt seem to be a way to force the scrollbar short of filling the list with empty junk. (Not willing to do that.)
Banging my head against the wall and getting nowhere here.
|
|
|
|
|
See here[^] and here[^] maybe its some helpful for you
|
|
|
|
|
I've also tried
my_list.ModifyStyle(0 ,WS_VSCROLL,0)
No luck there either.
|
|
|
|
|
Add LBS_DISABLENOSCROLL to the listbox control style.
If it's in a dialog resource you can set it in the properties window for the control in
visual studio.
Mark
|
|
|
|
|
Hi,
I am a beginner in MFC and i had to do the following task without using dialog:
A spreadsheet with:
- Number of columns and rows can be changed.
- Sell color and text color can be changed.
- Search capability.
- Size of sells can be changed.
Can anybody suggest to me what to use exactly, since i can't find a control or something that make a spreadsheet in a document/view application?
Thanks,
marwa
|
|
|
|
|
How about using Excel automation?
|
|
|
|
|
|
|
Thanks, but:
- what do you mean by Excell automation and how?
- CSpreadSheet creates an excel file, but i want to create a sheet or a table inside the window of my application, so it is not the solution.
|
|
|
|
|
marwa_fci wrote: - what do you mean by Excell automation and how?
- CSpreadSheet creates an excel file, but i want to create a sheet or a table inside the window of my application, so it is not the solution.
Dont worry about that, sounds like you need a grid, see the post from Max http://www.codeproject.com/script/comments/forums.asp?msg=1691852&forumid=1647#xx1691852xx[^] the grid from Chris M has lots of features and will do just what you need.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
You can reply to answers if they arent your answer
|
|
|
|
|
This is really starting to bug me.
I have created a VC8 MFC app that I am now trying to get to run on a W2K SP4 machine. This app runs with no problems on my XP SP2 machine that has VS2005 installed on it.
I have turned off all optimizations, added all the debug info, and generated .map and .pdb files for the app.
I use DrWatson (drwtsn32.exe v5.0.2195.6699) to generate a .log and .dmp file on the W2K machine when the crash occurs. I transfered those two files back to my dev machine.
I have narrowed the error down to this:
CMyApp::InitInstance()
{
<snip>
CMainFrame *pMainFrame = new CMainFrame;
if (!pMainFrame)
{
AfxMessageBox(_T("Mainframe c'tor failed"));
return FALSE;
}
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
{
AfxMessageBox(_T("LoadFrame failed"));
delete pMainFrame;
return FALSE;
}
I have absolutely no idea why the LoadFrame call fails, nor why deleting the pMainFrame pointer causes the app to crash. When I try to open the dump file in VS2005 I get an error "Debugging older format crashdumps is not supported."
Here is part of the DrWatson log file in case anybody sees something I may be missing:
State Dump for Thread Id 0x3b8
eax=00778f00 ebx=ffffffff ecx=00778f00 edx=00000000 esi=00433a68 edi=00433a68
eip=00423f8e esp=0012fe70 ebp=0012ff1c iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000206
function: <nosymbols>
00423f72 8b4df0 mov ecx,[ebp+0xf0] ss:00ba9e02=????????
00423f75 894d88 mov [ebp+0x88],ecx ss:00ba9e02=????????
00423f78 8b5588 mov edx,[ebp+0x88] ss:00ba9e02=????????
00423f7b 89558c mov [ebp+0x8c],edx ss:00ba9e02=????????
00423f7e 837d8c00 cmp dword ptr [ebp+0x8c],0x0 ss:00ba9e02=????????
00423f82 7417 jz 0042a99b
00423f84 6a01 push 0x1
00423f86 8b458c mov eax,[ebp+0x8c] ss:00ba9e02=????????
00423f89 8b10 mov edx,[eax] ds:00778f00=00000000
00423f8b 8b4d8c mov ecx,[ebp+0x8c] ss:00ba9e02=????????
FAULT ->00423f8e 8b4204 mov eax,[edx+0x4] ds:00a79ee6=????????
00423f91 ffd0 call eax
00423f93 898560ffffff mov [ebp+0xffffff60],eax ss:0012fe7c=00000040
00423f99 eb0a jmp 004306a5
00423f9b c78560ffffff00000000 ss:0012fe7c=00000040
mov dword ptr [ebp+0xffffff60],0x0
00423fa5 6a00 push 0x0
00423fa7 6a00 push 0x0
00423fa9 686caa4200 push 0x42aa6c
00423fae e84fcefeff call 00410e02
00423fb3 c7458400000000 mov dword ptr [ebp+0x84],0x0 ss:00ba9e02=????????
00423fba c745fcffffffff ss:00ba9e02=????????
mov dword ptr [ebp+0xfc],0xffffffff
00423fc1 8d4dbc lea ecx,[ebp+0xbc] ss:00ba9e02=????????
*----> Stack Back Trace <----*
FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name
0012FF1C 7831C3A7 00433BB4 00000001 00000000 00411561 !<nosymbols>
0012FFC0 7C4E87F5 006D0049 00670061 7FFDF000 C0000005 !<nosymbols>
0012FFF0 00000000 004116D1 00000000 000000C8 00000100 kernel32!DosDateTimeToFileTime
*----> Raw Stack Dump <----*
0012fe70 01 00 00 00 f5 ca 3c 8c - c8 fe 12 00 40 00 00 00 ......<.....@...
0012fe80 00 8f 77 00 80 8d 77 00 - 68 3a 43 00 76 00 00 00 ..w...w.h:C.v...
0012fe90 b0 ff 12 00 8e 13 2e 7c - a0 20 2d 7c ff ff ff ff .......|. -|....
0012fea0 d4 fe 12 00 00 8f 77 00 - 00 8f 77 00 c8 fe 12 00 ......w...w.....
0012feb0 00 8f 77 00 00 8f 77 00 - 08 ff 12 00 80 8d 77 00 ..w...w.......w.
0012fec0 80 8d 77 00 5c 6e 3c 78 - 76 00 78 00 e8 21 2f 78 ..w.\n<xv.x..!>
0012fed0 00 00 00 00 0c ff 12 00 - 18 27 2f 78 01 00 00 00 .........'/x....
0012fee0 00 00 00 00 00 00 00 00 - 00 00 00 00 e0 5c 3c 78 .............\<x>
0012fef0 e0 5c 3c 78 e0 5c 3c 78 - e0 5c 3c 78 00 00 00 00 .\<x.\><x.\><x....>
0012ff00 08 00 00 00 ff 00 00 00 - 80 8d 77 00 00 8f 77 00 ..........w...w.
0012ff10 b0 ff 12 00 a9 80 42 00 - 00 00 00 00 c0 ff 12 00 ......B.........
0012ff20 a7 c3 31 78 b4 3b 43 00 - 01 00 00 00 00 00 00 00 ..1x.;C.........
0012ff30 61 15 41 00 00 00 40 00 - 00 00 00 00 64 08 02 00 a.A...@.....d...
0012ff40 01 00 00 00 29 ca 3c 8c - 49 00 6d 00 61 00 67 00 ....).<.I.m.a.g.
0012ff50 00 f0 fd 7f 44 00 00 00 - 00 09 02 00 e0 08 02 00 ....D...........
0012ff60 68 08 02 00 00 00 00 00 - 00 00 00 00 00 00 00 00 h...............
0012ff70 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................
0012ff80 01 04 00 00 01 00 00 00 - 00 00 00 00 00 00 00 00 ................
0012ff90 01 00 01 00 00 00 00 00 - 05 00 00 c0 64 08 02 00 ............d...
0012ffa0 00 00 00 00 00 00 00 00 - 44 ff 12 00 a4 fa 12 00 ........D.......
*----> Symbol Table <----*
</x....></x.\></x.\></x></xv.x..!></nosymbols></nosymbols></nosymbols>
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
What's the value of IDR_MAINFRAME?
I don't think it's crashing where you think it is.... it doesn't look like delete.
<br />
00423f84 6a01 push 0x1<br />
00423f86 8b458c mov eax,[ebp+0x8c] ss:00ba9e02=????????<br />
00423f89 8b10 mov edx,[eax] ds:00778f00=00000000<br />
00423f8b 8b4d8c mov ecx,[ebp+0x8c] ss:00ba9e02=????????<br />
FAULT ->00423f8e 8b4204 mov eax,[edx+0x4] ds:00a79ee6=????????<br />
00423f91 ffd0 call eax<br />
00423f93 898560ffffff mov [ebp+0xffffff60],eax ss:0012fe7c=00000040<br />
00423f99 eb0a jmp 004306a5<br />
It's calling something out of a table. Loads eax with an address of a function (likely from a vtable) and then calls it. The only thing on the stack is a "1".
Just a guess, but the call to LoadFrame would be my guess.
But I am pretty sure it's not the delete statement.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc.</A>
|
|
|
|
|
The more I look at this the more confused and frustrated I become.
This is the view from the disassembly window when running the app in VS2005 on my XP machine:
{
AfxMessageBox(_T("LoadFrame failed"));
00423F04 push 0
00423F06 push 0
00423F08 push 42A950h
00423F0D call AfxMessageBox (410E02h)
delete pMainFrame;
00423F12 mov ecx,dword ptr [ebp-10h]
00423F15 mov dword ptr [ebp-78h],ecx
00423F18 mov edx,dword ptr [ebp-78h]
00423F1B mov dword ptr [ebp-74h],edx
00423F1E cmp dword ptr [ebp-74h],0
00423F22 je CMyApp::InitInstance+2CBh (423F3Bh)
00423F24 push 1
00423F26 mov eax,dword ptr [ebp-74h]
00423F29 mov edx,dword ptr [eax]
00423F2B mov ecx,dword ptr [ebp-74h]
00423F2E mov eax,dword ptr [edx+4]
00423F31 call eax
00423F33 mov dword ptr [ebp-0A0h],eax
00423F39 jmp CMyApp::InitInstance+2D5h (423F45h)
00423F3B mov dword ptr [ebp-0A0h],0
return FALSE;
00423F45 mov dword ptr [ebp-7Ch],0
00423F4C mov dword ptr [ebp-4],0FFFFFFFFh
00423F53 lea ecx,[ebp-44h]
00423F56 call CCommandLineInfo::~CCommandLineInfo (410DD8h)
00423F5B mov eax,dword ptr [ebp-7Ch]
00423F5E jmp 0042409A
}
m_pMainWnd = pMainFrame;
00423F63 mov ecx,dword ptr [ebp-94h]
00423F69 mov edx,dword ptr [ebp-10h]
00423F6C mov dword ptr [ecx+20h],edx And this is the DrWatson log from the same exe file but run on W2K
State Dump for Thread Id 0x3b8
eax=00778f00 ebx=ffffffff ecx=00778f00 edx=00000000 esi=00433a68 edi=00433a68
eip=00423f8e esp=0012fe70 ebp=0012ff1c iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000206
function: <nosymbols>
00423f72 8b4df0 mov ecx,[ebp+0xf0] ss:00ba9e02=????????
00423f75 894d88 mov [ebp+0x88],ecx ss:00ba9e02=????????
00423f78 8b5588 mov edx,[ebp+0x88] ss:00ba9e02=????????
00423f7b 89558c mov [ebp+0x8c],edx ss:00ba9e02=????????
00423f7e 837d8c00 cmp dword ptr [ebp+0x8c],0x0 ss:00ba9e02=????????
00423f82 7417 jz 0042a99b
00423f84 6a01 push 0x1
00423f86 8b458c mov eax,[ebp+0x8c] ss:00ba9e02=????????
00423f89 8b10 mov edx,[eax] ds:00778f00=00000000
00423f8b 8b4d8c mov ecx,[ebp+0x8c] ss:00ba9e02=????????
FAULT ->00423f8e 8b4204 mov eax,[edx+0x4] ds:00a79ee6=????????
00423f91 ffd0 call eax
00423f93 898560ffffff mov [ebp+0xffffff60],eax ss:0012fe7c=00000040
00423f99 eb0a jmp 004306a5
00423f9b c78560ffffff00000000 ss:0012fe7c=00000040
mov dword ptr [ebp+0xffffff60],0x0
00423fa5 6a00 push 0x0
00423fa7 6a00 push 0x0
00423fa9 686caa4200 push 0x42aa6c
00423fae e84fcefeff call 00410e02
00423fb3 c7458400000000 mov dword ptr [ebp+0x84],0x0 ss:00ba9e02=????????
00423fba c745fcffffffff ss:00ba9e02=????????
mov dword ptr [ebp+0xfc],0xffffffff
00423fc1 8d4dbc lea ecx,[ebp+0xbc] ss:00ba9e02=????????
*----> Stack Back Trace <----* Now I do not know why the addresses are different (off by 0x60 bytes)
Why the instruction just before the push 1 is different - VS debugger has it as jz, DrWatson has it as je
Why the pointers are different? mov ecx,dword ptr [ebp-10h] as opposed to mov ecx,[ebp+0xf0]
Is the copy of DrWatson on the W2K machine all screwed up?
If I look for the instruction addresses reported by DrWatson in VS I can not find them.
I assumed that the app was crashing in delete because it crashed immediately after I got the message box and DrWatson reported the fault to be in the code that matches up (almost) with the code the VS shows for the delete function.
Why would the app run flawlessly on XP but crash so badly on W2K? I think what I really need is some clear instructions on how to setup VS2005 to do remote debugging. Anything I have tried from reading MSDN on the subject has failed with VS giving me cryptic error messages.
|
|
|
|
|
JE and JZ are synonymous - both jump if the zero flag is set. cmp eax, 15 checks if eax==15. But what it really does is subtract 15 from eax and set the flags appropriately. Thus if they are equal, the zero-flag will be set.
As for the different pointers - the instructions in question have a sign-extended MOD/RM operand. Dr.Watson is for some reason treating the offset as an unsigned char rather than the signed char it really is.
I still don't know why the load addresses are different. You're not doing anything funky with EXE alignment, are you?
It looks to me like memory corruption. It is failing while trying to load the address of the virtual destructor of the pMainFrame object. Somehow the vtbl pointer has been zeroed out. Are you by any chance doing a memset to clear a bunch of class variables? I've seen that many times.
But as to why this fails on only W2K, I have no idea at the moment. What kind of stuff does the app use? (i.e. any os components that could be different on 2k/xp?)
That doesn't really help much, now, does it But it's about all I can think of now.
Mike
|
|
|
|
|
Mike_V wrote: What kind of stuff does the app use? (i.e. any os components that could be different on 2k/xp?)
BINGO !!!!
I was using the CS_DROPSHADOW style on a floating tool window. Removed that style and everything worked.
Thanks much for the hint. You get my 5 for that
|
|
|
|
|
Cool!
I guess I've been reading Raymond Chen's blog enough that some of his "psychic powers" have rubbed off on me!
But seriously - glad to be of help. Though I still don't get why that caused the problem we were seeing. But at this point it's probably better not to ask.
Mike
|
|
|
|
|
Mike_V wrote: Though I still don't get why that caused the problem we were seeing. But at this point it's probably better not to ask.
This code was called from CMainFrame::OnCreate()
BOOL CToolWnd::Create(CWnd *pParent)
{
return CreateEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
AfxRegisterClass(CS_DROPSHADOW | CS_SAVEBITS,
NULL, NULL, NULL),
...);
} I would have thought that the the create function would simply fail to create a window, not crash the entire app. It certainly would have been easier to debug . I have now added code to check the OS and remove the CS_DROPSHADOW style if running on W2K.
Maybe a guy should not ask why, but I would really like to know if anybody has any idea
|
|
|
|
|