|
firelife2911 wrote: 1: How do i program it to search and validate a filename? (the file to be saved from the server) Also i need it to find the size of the file so that i know it will fit in the storage space(these are very large files).
If you're using Win32, look up FindFirstFile , FindNextFile and their siblings. If you're using MFC then you might find CFindFile easier to deal with.
firelife2911 wrote: 2: How do i change the name of the file to another names with the date (such as 11-11-1111) added on the end?
When you call CopyFile , you can use the lpNewFileName parameter to specify the name of the file to use at the copied location.
firelife2911 wrote: 3: How do i make this into a .exe program that can be run automatically?
Use Windows Scheduler (Control Panel\Scheduled Tasks). You can also use the "at" command from a command line to schedule tasks which is just another interface for the Windows Scheduler service.
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|
|
Hi everyone,
I was referred here. The person doesn't come here but he does cross this forum a lot by Google. He told me to check it. I have some questions below.
I am currently reading C Primer Plus to learn pure C. Will someone recommend books to read that builds on C Primer Plus? Would anyone recommend C The Complete Reference? Will someone post books starting with the basics for C and C++? I am reading the basics for C. I never done C++. I never done C execpt for reading this book. Thank you for any replies.
|
|
|
|
|
I can suggest these books
for C
Beginning C (From Novice to professional)
fourth edition
author:
Ivor Horton
-----------------------------------------
for C++
Windows C/C++,Fifth Edition
authors:
Jeffrey Richter
(Wintellect)
Christophe Nasarre
Good luck.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
|
Learning C++, A Hands on Approach by Eric Nagler is a nice choice.
The C++ Programming Language by it's creator is one of the definite book on C++.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Hamid,
Hamid. wrote: for C++
Windows C/C++,Fifth Edition
authors:
Jeffrey Richter
(Wintellect)
Christophe Nasarre
I doubt Windows Via C/C++ is a good book for learning C++. Because it's ultimate target is to program windows using windows APIs and explaining how to use and explore different features and services from window in a developer perspective.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
If Windows C/C++ isn't good. What is good? I am looking for a list of books to learn to advanced. I am talking about both pure C and C++. I am reading C Primer Plus as for learning pure C. What comes after that book? What about after that one and so on? That is what I am looking for as in C and C++.
|
|
|
|
|
php111 wrote: If Windows C/C++ isn't good. What is good?
I dint say that Windows Via C/C++ is not a good book. What I meant, it's a definite guide to program using Windows API but it's not a definite guide to learn Pure C++.
Windows Via C/C++ (and Programming Application for Windows is my favorite book of all time.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Hi,
I seldom recommend specific books, I tend to go to a book store, look at say 10 similar books and
choose 1 or 2. It is all very subjective, how familiar are you with programming, how much are you
interested in examples and exercises, etc.
|
|
|
|
|
|
This was my C++ primer: "Teach Yourself C++ in 21 Days" [^], Jesse's explanations of classes and inheritance are great for beginners.
Book teaches you C++ in logical and organized manner, and is perfect for beginners.
|
|
|
|
|
Does SetRegistryKey make the App registry default to ...\HKey_Current_User or is it decalred explicitly somwhere else, I would like to have some settings under .....\Hkey_Local_Machine for all users purposes.... Can someone clarify this for me a bit?
Thanks
sft
|
|
|
|
|
Software2007 wrote: Does SetRegistryKey make the App registry default to ...\HKey_Current_User
Yes. See the source code
It also only affects the "GetProfileInt, GetProfileString, WriteProfileInt,
and WriteProfileString member functions of CWinApp"
Software2007 wrote: I would like to have some settings under .....\Hkey_Local_Machine for all users purposes
Keep in mind that on Vista+, only app's running with elevated privileges will
be able to write to the HKLM key...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
http://msdn.microsoft.com/en-us/library/7c2w6z4k(VS.80).aspx[^] is pretty clear:
It is stored in a key of the following form: HKEY_CURRENT_USER\Software\<company name>\<application name>\<section name>\<value name>.
If you want something stored under HKLM, you'll have to (wo)man up and write some real code. That said, you'll run into lots of problems trying to set it from any old user - it's all securitied, and for good reason.
For me, I use HKLM for machine parameters (ie, this machine has 5 motors) that are use independent, and KHCU for most others (ie, "I like blue!")
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi guys,
I'm attempting to add network printers to a local machine, only I've run into some trouble with the AddPrinter call. Essentially it returns 0 for the handle and doesn't tell me anything with GetLastError - I read somewhere this is a bug in the API, but don't know if its still there ( although, it appears so !)
Code goes like so:
PRINTER_INFO_2 *pi1=NULL;
DWORD size(0), numOfPrinters(0);
EnumPrinters(PRINTER_ENUM_NAME, (LPSTR)strPrintServerName.c_str(), 2, NULL, 0, (LPDWORD)&size, (LPDWORD)&numOfPrinters);
pi1 = new PRINTER_INFO_2[numOfPrinters+1];
if (EnumPrinters(PRINTER_ENUM_NAME, (LPSTR)strPrintServerName.c_str(), 2, (LPBYTE)pi1, size, (LPDWORD)&size, (LPDWORD)&numOfPrinters))
{
for(unsigned int i=0; i<numOfPrinters; i++)
{
PRINTER_INFO_2 *pi2 = &pi1[i];
std::cout << pi2->pPrinterName << std::endl;
HANDLE hPrinter(0);
hPrinter = AddPrinter(pi2->pPrinterName, 2, (LPBYTE)pi2);
if (hPrinter != 0)
{
std::cout << "Printer handle " << hPrinter << std::endl;
}
else
{
std::cout << "Failed to add printer " << pi2->pPrinterName << std::endl;
}
}
}
else
{
std::cout << "Enum Call failed - " << GetLastError() << std::endl;
}
delete [] pi1;
Any help you can offer would be much appreciated!
Andrew
|
|
|
|
|
Why are you passing pi2->pPrinterName in as the first parameter to AddPrinter? According to http://msdn.microsoft.com/en-us/library/ms535500(VS.85).aspx[^] this should be NULL for local printers.
You may also have to change the pServerName and Attributes members of the PRINER_INFO_2 structure (if only to remove the PRINTER_ATTRIBUTE_NETWORK part)
|
|
|
|
|
Its not a local printer. Its one of the printers hanging of the print server, that was returned in the EnumPrinters call.
Are you saying if I want to install a shared network printer, I still need to pass NULL to this function? (Just noticed I was passing the printer name instead of the server name anyway)
The call still fails using the print server name of NULL...
|
|
|
|
|
I assumed you were trying to copy the connected (network) printers for some reason. You enumerate the printers, then loop through and add them all again, it looks like to me.
|
|
|
|
|
What I'm trying to do is programmatically add network printers to a local terminal (minimum. 2K).
Am I going about it the right way?
|
|
|
|
|
I don't understand what you're trying to do. The printers are already connected (or else EnumPrinters wouldn't find them). Why do you need to connect to them again?
|
|
|
|
|
I need to programatically allow certain users access to the printers attached to the server.
If they're not authorised then they can't see the printers.
The printers are connected to the server and I want to bypass the usual way you would add a network printer via the GUI.
|
|
|
|
|
I am using CProperySheet and CPropertyPage in my application for creating tabbed dialog boxes.
For providing the RTL layout, I am using the WS_EX_LAYOUTRTL for Property Sheet and Property Pages both.
This is doing well.
The Titla bar ( System control and min/max/restore buttons) are now in RTL layout.
Tabs contents are also in RTL layout. However two issues are still remaining opened-
1. OK and CANCEL buttons (that were in the Right Side of the screen before applying WS_EX_LAYOUTRTL style) are now in the Middle of the screen. They should be in the Left of the screen.
(Point to notice is that i have hide the "Help" and "Apply" buttons.)
2. Tabs (Tab Bar) are still coming in the Left side of the screen. No effect of the RTL layout on the tabs (Tab Bar) alignment or in their order.
<br />
void CAllControlsSheet::AddControlPages()<br />
{<br />
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);<br />
m_psh.dwFlags |= PSP_USEHICON;<br />
m_psh.hIcon = m_hIcon;<br />
m_psh.dwFlags |= PSH_NOAPPLYNOW;
m_psh.dwFlags |= PSH_RTLREADING ; <br />
m_psh.dwFlags &= ~PSH_HASHELP;
<br />
Invalidate();<br />
<br />
AddPage(&m_treectrlpage);<br />
AddPage(&m_animctrlpage);<br />
AddPage(&m_toolbarpage);<br />
AddPage(&m_datetimepage);<br />
AddPage(&m_monthcalpage);<br />
<br />
}<br />
<br />
BEGIN_MESSAGE_MAP(CAllControlsSheet, CPropertySheet)<br />
ON_WM_QUERYDRAGICON()<br />
ON_WM_SYSCOMMAND()<br />
END_MESSAGE_MAP()<br />
<br />
<br />
BOOL CAllControlsSheet::OnInitDialog()<br />
{<br />
<br />
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);<br />
ASSERT(IDM_ABOUTBOX < 0xF000);<br />
<br />
CMenu* pSysMenu = GetSystemMenu(FALSE);<br />
if (pSysMenu != NULL)<br />
{<br />
CString strAboutMenu;<br />
strAboutMenu.LoadString(IDS_ABOUTBOX);<br />
if (!strAboutMenu.IsEmpty())<br />
{<br />
pSysMenu->AppendMenu(MF_SEPARATOR);<br />
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);<br />
}<br />
}<br />
<br />
SetIcon(m_hIcon, TRUE);<br />
SetIcon(m_hIcon, FALSE);<br />
ModifyStyleEx(0, WS_EX_LAYOUTRTL); <br />
return CPropertySheet::OnInitDialog();<br />
}<br />
<br />
|
|
|
|
|
How can I do it ?
Trying with the following code is not helpful :
<br />
wofstream fout;<br />
fout.open(fileTo, ios_base::out | ios_base::trunc | ios_base::binary);<br />
fout << content.c_str();<br />
fout << flush;<br />
fout.close();<br />
(where content is of type std::wstring)
Are there special header characters I need to insert in order to indicate to a standard UTF-8 text file reader (such as NotePad) that the file is actually encoded in UTF-8 ??
Thank you in advance.
modified on Wednesday, January 14, 2009 1:09 PM
|
|
|
|
|
Here's one way:
wstring content = L"Test String";
ofstream fout;
fout.open("e:\\testutf8.txt", ios_base::out | ios_base::trunc | ios_base::binary);
fout.write("\xEF\xBB\xBF", 3);
int bufsize = ::WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, NULL, 0, NULL, NULL);
LPSTR buf = new CHAR[bufsize];
bufsize = ::WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, buf, bufsize, NULL, NULL);
fout.write(buf, bufsize-1);
fout << flush;
fout.close();
delete[] buf;
That should match what Notepad writes.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello Mark,
Thank you very much it works fine.
I did many ways but all were in vain. Main reason was because I convinced my self that it has necessarily to be done
through an wofstreamù instead of ofstream in order to handle the std::wstring content..
many thanks indeed.
|
|
|
|