|
CString str="C:\MyDocuments\myDialog\release\myapp.exe"
int indx=str.ReverseFind('\\');
if (indx!=-1)
CString fileName=str.Right(indx);
|
|
|
|
|
Why don't you check out the Class Members in CString?
Well, here goes:
Solution 1, CString:
CString cs = "C:\\MyDocuments\\myDialog\\release\\myapp.exe";
CString pureFileName;
int lastSlashOffset = cs.ReverseFind((TCHAR) '\\');
if(lastSlashOffset >= 0 && cs.GetLength > (lastSlashOffset + 1)) {
pureFileName = cs.Mid(pureFileName + 1);
}
// pureFileName contains the file name.
Solution 2 (good old splitpath):
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
char path_buffer[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
strcpy(path_buffer, "C:\\MyDocuments\\myDialog\\release\\myapp.exe");
_splitpath( path_buffer, drive, dir, fname, ext );
printf( "Path extracted with _splitpath:\n" );
printf( " Drive: %s\n", drive );
printf( " Dir: %s\n", dir );
printf( " Filename: %s\n", fname );
printf( " Ext: %s\n", ext );
}
Output
Path extracted with _splitpath:
Drive: c:
Dir: \MyDocuments\myDialog\release\
Filename: myapp
Ext: .exe
|
|
|
|
|
This is the code that i have Tested with VC.6
it is actually the correction of the answer posted to the
quetion .
If ur using CString so its VC++ and for VC++ this format
is preferable.
<br />
CString str1="C:\\MyDocuments\\myDialog\\release\\myapp.exe";<br />
int indx=str1.ReverseFind('\\');<br />
indx++;<br />
if (indx!=-1)<br />
CString fileName=str1.Mid(indx);<br />
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
OOps ! I forgot to increment. thanks Vikas.
|
|
|
|
|
#include "shlwapi.h"
CString strPathName = _T("C:\\MyDocuments\\myDialog\\release\\myapp.exe");
LPTSTR pszFileName = PathFindFileName(strPathName);
CString strFileName = pszFileName;
Never forget to search MSDN.
That's all, folks!
One always gets the deserved.
|
|
|
|
|
YoSilver wrote:
PathFindFileName(strPathName);
Similarly you can use _tSplitPath() api also
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
i want to chang the data of VT_DATE to the one of VT_BSTR with the VariantChangeTypeEx(&vargDest,&varSrc,2052,0,VT_BSTR) function, but only a part of the data is changed. for example,2005-12-20 0:00:00 is converted to 2005-12-20 of VT_BSTR, but 1899-12-30 21:30:00 is converted to 21:30:00 of VT_BSTR. both 2005-12-20 0:00:00 and 1899-12-30 21:30:00 are from sql server, and 2005-12-20 0:00:00 is smalldatetime; 1899-12-30 21:30:00 is datetime. how can i get the complete VT_BSTR data?
|
|
|
|
|
hi everyone, i want to write some letters on a sphere to give the letters third dimension, and i don't want to use openGl or DirectX, how ?
thanks in advance!
|
|
|
|
|
why not use one of them? If you want to do it yourself then you need to understand the maths involved.
If you just want a simple solution then draw the letters at the middle of the string bigger than at each end.
|
|
|
|
|
sounds like a good idea, i'll try. thanks again
|
|
|
|
|
i have tried,it looks uglily, maybe it is the time to review maths
|
|
|
|
|
In vc6 project with vss, what do the two icons in front of each file mean (one with a downward arrow, one without)? Thanks.
|
|
|
|
|
I have referred to the FAQ but the answer does not solve the problem actually...
Below is my code of creating srevice:
--------------------------------------------------------------------------------------------------
SC_HANDLE hService =
::CreateService(
handle, // handle to SCM database
servicename.c_str(), // name of the service to install
servicename.c_str(), // name that is displayed on SCM
SERVICE_ALL_ACCESS, // can be accessed only by administrators
SERVICE_WIN32_OWN_PROCESS, // service runs its own process
SERVICE_AUTO_START, // started by SCM when StartService() is called
SERVICE_ERROR_IGNORE, // error logged but service started
ss, // pathname of the executable
NULL, // service does not belong to any group
NULL, // service does not use a tag
NULL, // requires NtLmsSp and EventLog service to be running
".\\Administrator", // user name to log on
"s" // password
);
--------------------------------------------------------------------------------------------------
|
|
|
|
|
Hi!Dear,
I got a Link error when compile my windows app on visual studio c++ 6.0.
It says:
"LINK:fatal error LNK1104:can not open file '..\..\baseclasses\debug_unicode\quartz.lib'".
My Project Options:..\..baseclasses\debug_unicode\quartz.lib kernel32.lib ...
And when I changed by Project Options as:
:..\..baseclasses\debug_unicode\kernel32.lib quartz.lib ...
then the link error says:
"LINK:fatal error LNK1104:can not open file '..\..\baseclasses\debug_unicode\kernel32.lib'"
But I am quite sure that I have added the directories of these libray files.
Then,how to kill this matter?
Thanks!
|
|
|
|
|
momer wrote:
"LINK:fatal error LNK1104:can not open file '..\..\baseclasses\debug_unicode\quartz.lib'".
Do these files exist ? Apparently, they are not visible to the compiler.
momer wrote:
But I am quite sure that I have added the directories of these libray files.
Yes, but if you've added their directories to VC, then you need to link to just the file, and not a relative path to the file. Try removing all but the lib name and see how you go.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If I remember correectly, quartz.lib is part of media player 9 so reinstall that.
Elaine
PS "Madam, can you help me" was appropriate here
The tigress is here
|
|
|
|
|
Trollslayer wrote:
"Madam, can you help me"
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Which is faster when doing a file search on your pc programmatically? CRC's or byte-for-byte checking?
|
|
|
|
|
benjnp wrote:
Which is faster when doing a file search on your pc programmatically? CRC's or byte-for-byte checking?
Offcourse CRC, but what the use of that in file search
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
hello
I am experimenting with simulating a key press using the SetKeyboardState
<br />
while(true)<br />
{<br />
<br />
DWORD thread_acum=GetWindowThreadProcessId(GetActiveWindow(),NULL);<br />
<br />
UINT vk,scan;<br />
<br />
LPARAM lparam;<br />
<br />
vk = VkKeyScan('s');<br />
<br />
<br />
AttachThreadInput(thread_acum,GetCurrentThreadId(),TRUE);<br />
<br />
<br />
BYTE byKeybState[256];<br />
GetKeyboardState(byKeybState); <br />
byKeybState[vk] =! (BOOL)::GetKeyState(vk);<br />
<br />
<br />
byKeybState[vk] =!(BOOL)GetKeyState(vk);<br />
SetKeyboardState(byKeybState);<br />
<br />
<br />
<br />
<br />
AttachThreadInput(thread_acum,GetCurrentThreadId(),FALSE);<br />
<br />
<br />
<br />
<br />
Sleep(1000);<br />
<br />
}<br />
why does this not work? No key is pressed
|
|
|
|
|
Spiritofamerica wrote:
SetKeyboardState
Why Don't you use SendInput Api or KeyBD_event api..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
because I have the latest version of zonealarm installed on my sytem and it doesn't allow these functions any more
I am not trying to do anything illegal with this but I saw it in a article and said hey I should try this
and it doesn't work
So far za doesn't object to me using this function but it doesn't work
for the others you mention above and for PostMessage(WM_KEYUP) it gives me worning messages
so there are 2 reasons
1. I don't wanna upset za
2.I wanna do it with this function
|
|
|
|
|
hi, all
Windbg supposed to the default debugger on my machine, but when the app is hang, I could get this message "Cannot debug pid 1784, Win32 error 87 The Parameter is incorrect"......why is that?
If I open windbg and attach the process, it would work, so for this app, Dumping objects ->
{360} normal block at 0x00F01F58, 38084 bytes long.
Data: < `Ce v > 88 00 00 00 60 43 65 00 8C 76 13 00 00 00 00 00
{359} normal block at 0x00F01F10, 18 bytes long.
Data: <data\customer.db> 44 61 74 61 5C 43 75 73 74 6F 6D 65 72 2E 64 62
{358} normal block at 0x00EF0878, 100 bytes long.
Data: < !e v > 04 21 65 00 88 00 00 00 10 1F F0 00 8C 76 13 00
{160} normal block at 0x00EF92F8, 35004 bytes long.
Data: <} `Ce 4z > 7D 00 00 00 60 43 65 00 34 7A 13 00 00 00 00 00
{159} normal block at 0x00EF04D8, 17 bytes long.
Data: <data\sysfile.dbf> 44 61 74 61 5C 53 79 73 66 69 6C 65 2E 64 62 66
{158} normal block at 0x00EF0440, 100 bytes long.
Data: < !e } 4z > 04 21 65 00 7D 00 00 00 D8 04 EF 00 34 7A 13 00
Object dump complete.
eax=00000000 ebx=7ffdf000 ecx=000c4006 edx=00000000 esi=77f8ee04 edi=00000000
eip=77f8ee0f esp=0012fe50 ebp=0012ff18 iopl=0 nv up ei pl zr na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246
ntdll!NtTerminateProcess+0xb:
77f8ee0f c20800 ret 0x8
0:000> ~
. 0 Id: 984.7bc Suspend: 0 Teb: 7ffde000 Unfrozen
0:000> kb
ChildEBP RetAddr Args to Child
0012fe4c 7c5969e4 ffffffff 00000000 001358f8 ntdll!NtTerminateProcess+0xb
0012ff18 0046470f 00000000 00ef8024 0012ff3c KERNEL32!ExitProcess+0x72
WARNING: Stack unwind information not available. Following frames may be wrong.
0012ff28 004645c0 00000000 00000000 00000000 AddSurchrg!CDate::operator--+0x26f1f
0012ff3c 0045e312 00000000 001358f8 0012f5a4 AddSurchrg!CDate::operator--+0x26dd0
0012ffc0 7c59893d 001358f8 0012f5a4 7ffdf000 AddSurchrg!CDate::operator--+0x20b22
0012fff0 00000000 0045e1e0 00000000 000000c8 KERNEL32!BaseProcessStart+0x3d
looks like the memory leak happened before it crashes, but couldn't tell why is it crashing beside the memory leak. thank you!
|
|
|
|
|
Hello,
I am working on a project and I am stuck at one place. I have 2 applications.
1-> ActiveX Control (Developed in MFC)
2-> A Windows C++ application.(No MFC...purely Windows)
How can I use the functions defined in ActiveX into this C++ application. I tried adding the ActiveX header file in my C++ application but then I get an error of CWnd, CString etc classes of MFC not found.
Please let me know if you or any of your friends know the solution. Please email me at dubeyashok@yahoo.com
Thanks in Advance.
Ashok Dubey
Ashok
|
|
|
|
|
Ashok,
I'm no expert yet on mfc, but from what I've seen, mfc is nothing more than a bunch of wrapper code around the win32 functions. So, I don't think there is any reason why you cannot do this. I would suggest creating a dummy mcf application with ActiveX support. Take a look at the stdafx header file. Also, there your Windows app must call AfxEnableControlContainer(); You'll see all of this in your dummy application.
You should get pretty far with this approach.
chg
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|