|
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
|
|
|
|
|
Hi,
Did you include Windows.h header ?
-----------
Mila
|
|
|
|
|
Hi Mila,
Thanks for the response.
I have included windows.h and I forgot to include #include "commdlg.h" .
|
|
|
|
|
|
Oops I forgot to include #include "commdlg.h"
Now the error have gone Thanks a lot Prasad.
|
|
|
|
|
When Our application is running, we are able to rename the .exe file from C:\Program files. How can we prevent the file or the folder from getting renamed?? Please post your suggestions..
Thanks for your time and help !!!
|
|
|
|
|
i think this is only possible if your exe is running from some other directory (i.e. not from C:\Program Files\) try running the executable by going to the directory and running it from there and then try renaming it.. As far as i remember i read somewhere that window's paging and filesystem machenism prevents the file to be renamed if its already being used!
|
|
|
|
|
The exe is not present in C:\Program Files. It is present inside a folder with the application name but it still allows me to rename the exe file.
|
|
|
|
|
When your app launches, try opening itself with a call to OpenFile() and set the permissions very high. This should in effect lock the file preventing other processes from deleting or renaming it. Remember to release the handle when your program terminates.
|
|
|
|
|
If I try to rename an application like Yahoo messenger when it is running..It gives me an error message
"ERROR: Unable to rename.It is being used by another person or program.
Close any programs that might be using the file and try again."
How do I do this for my application also??? So that when anyone tries to rename my application exe, when it is running, this error message appears and they are unable to rename the file..
Please post your suggestions.
Thanx!!!
|
|
|
|
|
Hi all,
I receive the following error:
Unhandled exception at 0x0045b287 in updCnf32.exe. 0xC0000005: Access violation writing location 0x00666e63.
Code (xutilty : compiler open this file):
inline void __CLR_OR_THIS_CALL _Container_base::_Orphan_all() const
{
_Lockit _Lock(_LOCK_DEBUG);
if (_Myfirstiter != _IGNORE_MYITERLIST)
{
for (_Iterator_base **_Pnext = (_Iterator_base **)&_Myfirstiter;
*_Pnext != 0; *_Pnext = (*_Pnext)->_Mynextiter)
(*_Pnext)->_Mycont = 0;
*(_Iterator_base **)&_Myfirstiter = 0;
}
}
This is my code:
for(int i=0; i < (int)getFileNamesString.size(); i++)
{
getFNamesString = CIniFile::GetSection(getFileNamesString[i], applicationFname);
for(int i=0; i < (int)getFNamesString.size(); i++)
cout << "File Names -> " << getFNamesString[i].Key.c_str() << "=" << getFNamesString[i].Value << endl;
}
string FileName = getFNamesString[0].Value;
string updateFName = getFNamesString[1].Value;
printf("Creating Directory\n");
TCHAR szDirPath[] = TEXT("C:\\Test\\");
if (!CreateDirectory(szDirPath, NULL))
{
printf("Could not create new directory.\n");
getch();
return -1;
}
else
printf("Directory Created...\n\n");
strcat((char*)szDirPath, (const char*)updateFName.c_str());
char lpExistingFileName[BUF_SIZE];
char lpNewFileName[BUF_SIZE];
strcpy((char*)lpExistingFileName, (const char*)updateFName.c_str());
strcpy((char*)lpNewFileName ,(const char*)szDirPath);
if(CopyFile((LPCTSTR)lpExistingFileName,(LPCTSTR)lpNewFileName,FALSE))
printf("File was copied successfully...\n");
else
printf("File copy failed....\n");
bool SecRc = false;
vector<string> getSecNameString = CIniFile::GetSectionNames(FileName);
for(int i=0; i < (int)getSecNameString.size(); i++)
{
vector<CIniFile::Record> getSecString = CIniFile::GetSection(getSecNameString[i], FileName);
for(int i=0; i < (int)getSecString.size(); i++)
{
if (CIniFile::SetValue(getSecString[i].Key,getSecString[i].Value,getSecString[i].Section,updateFName))
SecRc = true;
else
SecRc = false;
}
}
if (SecRc)
printf("\nSuccess...\nPress any key to continue....");
else
printf("\nFailed...\nPress any key to continue....");
getch();
return 0;
Many thanx ( .. ..)
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Did you use your debugger to see where the problem in your code is ? Can you tell us more about where it happens and what are the value of your variables at this point ?
|
|
|
|
|
Thanx for the reply Cedric,
The exception happens right at this point:
As I press any key, for the getch() the exception occurs.
getch();
return 0;
}
Does this help?
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|