|
Hi,
How can I get the last part ("1") of the file name using strstr or something else ???
char dtSrt[BUF_SIZE] = "C:\\Test\\6.20.1.txt"
char *pdest;
pdest = strstr(dtSrt,"");
Thnx again
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Searching a bit longer proves to be a good option for me ....
char dtSrt[BUF_SIZE] = "C:\\Test\\6.20.1.txt"
char *pdest;
pdest = strrchr(dtSrt,'.');
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
char dtSrt[BUF_SIZE] = "C:\\Test\\6.20.1.txt";
char *pdest = 0;
pdest = strrchr( dtSrt,".");
if( pdest > dtSrt )
{
char c = pdest[ -1 ];
}
nave
|
|
|
|
|
This will point you to the dot separating the file's name from its extension:
char *pExt = PathFindExtension(dtSrt);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I want to lock a file so that another application will not be able to open it. I am using CFile.open method with the flags CFile::modeRead|CFile::shareExclusive. However, after opening the file (and keeping it open) I am able to open the file using the windows api CreateFile function. How can I lock the file so that, the CreateFile function will fail?
C++beginer
|
|
|
|
|
ashokvishnu wrote: I am able to open the file using the windows api CreateFile function.
Can you show code ?
|
|
|
|
|
I found out the problem. If you use createfile function with dwDesiredAccess flag as 0, then it will not try to open the file. It will only check whether the file exists.
C++beginer
|
|
|
|
|
ashokvishnu wrote: I found out the problem. If you use createfile function with dwDesiredAccess flag as 0, then it will not try to open the file. It will only check whether the file exists.
I don't think that is a solution, at least for the problem you posted.
What will happen if another application tries to open your file?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
if you can send the file, may be someone can chk it. I don't understand any particular reason for this to be possible. Like i told you window's does force not to write on a file that is being used.. u can get the exact details from the book "Windows Driver Development"
best of luck
|
|
|
|
|
i am preparing application to test sound at different speaker configuration for Windows vista and Windows XP.
for doing this i am using API SetSpeakerConfig() to set the different configuration and API GetSpeakerConfig()for getting same configuration.
this is working fine in Windows XP. but not in Windows Vista.
The call to SetSpeakerConfig() succeeds in Vista, but doesn't actually change anything.
Is there any way other than by using the Sound control panel.
pavan
|
|
|
|
|
Use waveOutGetDevCaps() and waveOutGetVolume() and waveOutSetVolume() APIs.
|
|
|
|
|
Hi,
Is there a function or something I can use to just get the current year?
Thnx
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
What about COleDateTime::GetYear ?
|
|
|
|
|
Programm3r wrote: Is there a function or something I can use to just get the current year?
SYSTEMTIME sys;
GetSystemTime (&sys);
//sys.wYear has the year that you require
Also you can have a look at
CTime::GetYear()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
check GetLocalTime()
nave
|
|
|
|
|
have a look at CTime::GetYear .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thnx alot everyone, wow that was quick ....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
last day posted some pblm saying "application not working in another mechine...."
What about that. Was that solved?
nave
|
|
|
|
|
Well, yes and no. If I statically link some libraries to the application and fiddle with it's settings it works (local & other computers), and on the other hand if I don't do it I get and error when I want to run the exe on a different machine. Someone told me it has to do with CRT dll's and the whole .Net Framework ... and it's a long story ... thanx for asking Naveen
Regards
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Hi,
I have to convert a text report to a PDF file...
I done the first half., and now i have to create the PDF file from the text file... (ie., "murugan.txt"-->"murugan.pdf").
In one of a forum told that we can do this using CFile,CSTDIO FILE..
i don't know how to handle the conversion with the help of these files.,
can any one pls help me to do this.,
thank for your great help.
murugan.K
|
|
|
|
|
Murugan k wrote: In one of a forum told that we can do this using CFile,CSTDIO FILE..
Wow, that would need that you need to know the format of PDF and encode everything yourself. That's a quite a bit extreme. Why don't you simply use an existing library that does the job for you ?
You can find one here[^] for example (I'm sure if you search a little bit, you'll find plenty of).
|
|
|
|
|
Hi all,
I have to maintain log file of my application ?
is there any library which i can use in my application for maintainig log file.
also i have to define capacity for that log file at the end of the capacity of that log file this library take backup of that file at particular location.
i can bye also if it is not available free.
if anybody have idea about the same please reply me.
thanks
bankey
|
|
|
|
|
|
|
Hello All,
I have a List Box { IDC_FILE_LIST } and add button { IDC_FILE }
When we click on the add button it should popup a window where we can browse some file name with path and it should be added to list box.
For that I have used the below code but I am getting errors can anyone please tell me what is wrong in the below code.
[code]
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_FILE:
OpenFile(hwnd);
break;
---
----
Function OpenFile : -
void OpenFile(HWND hwnd)
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "txt";
if(GetOpenFileName(&ofn))
{
HWND hEdit = GetDlgItem(hwnd, IDC_FILE_LIST);
SendDlgItemMessage(hwnd, IDC_FILE_LIST, LB_ADDSTRING, 0, (LPARAM)ofn);
}
}
[\code]
Errors : -
(134) : error C2065: 'OPENFILENAME' : undeclared identifier
(134) : error C2146: syntax error : missing ';' before identifier 'ofn'
(134) : error C2065: 'ofn' : undeclared identifier
(139) : error C2228: left of '.lStructSize' must have class/struct/union type
(140) : error C2228: left of '.hwndOwner' must have class/struct/union type
(141) : error C2228: left of '.lpstrFilter' must have class/struct/union type
(142) : error C2228: left of '.lpstrFile' must have class/struct/union type
(143) : error C2228: left of '.nMaxFile' must have class/struct/union type
(144) : error C2228: left of '.Flags' must have class/struct/union type
(144) : error C2065: 'OFN_EXPLORER' : undeclared identifier
(144) : error C2065: 'OFN_FILEMUSTEXIST' : undeclared identifier
(144) : error C2065: 'OFN_HIDEREADONLY' : undeclared identifier
(145) : error C2228: left of '.lpstrDefExt' must have class/struct/union type
(147) : error C2065: 'GetOpenFileName' : undeclared identifier
---------
Thanking you,
Suresh HC
|
|
|
|