Click here to Skip to main content
15,918,889 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to cancel long time drawing Pin
David Crow17-Apr-09 2:23
David Crow17-Apr-09 2:23 
QuestionHow to retrieve bits from a file using MFC Pin
Pankaj D.Dubey13-Apr-09 20:36
Pankaj D.Dubey13-Apr-09 20:36 
AnswerRe: How to retrieve bits from a file using MFC Pin
Cedric Moonen13-Apr-09 20:56
Cedric Moonen13-Apr-09 20:56 
AnswerRe: How to retrieve bits from a file using MFC Pin
KarstenK13-Apr-09 21:13
mveKarstenK13-Apr-09 21:13 
QuestionRegwrite in bat file Pin
p_196013-Apr-09 20:09
p_196013-Apr-09 20:09 
AnswerRe: Regwrite in bat file Pin
_AnsHUMAN_ 13-Apr-09 20:19
_AnsHUMAN_ 13-Apr-09 20:19 
AnswerRe: Regwrite in bat file Pin
birajendu13-Apr-09 20:19
birajendu13-Apr-09 20:19 
QuestionHOW TO MAKE A WIN32 APPLICATION NOT INHERITING FROM EXPLORER.EXE? Pin
birajendu13-Apr-09 20:02
birajendu13-Apr-09 20:02 
AnswerRe: HOW TO MAKE A WIN32 APPLICATION NOT INHERITING FROM EXPLORER.EXE? Pin
_AnsHUMAN_ 13-Apr-09 20:14
_AnsHUMAN_ 13-Apr-09 20:14 
GeneralRe: HOW TO MAKE A WIN32 APPLICATION NOT INHERITING FROM EXPLORER.EXE? Pin
birajendu13-Apr-09 20:26
birajendu13-Apr-09 20:26 
GeneralRe: HOW TO MAKE A WIN32 APPLICATION NOT INHERITING FROM EXPLORER.EXE? Pin
Cedric Moonen13-Apr-09 20:35
Cedric Moonen13-Apr-09 20:35 
GeneralRe: HOW TO MAKE A WIN32 APPLICATION NOT INHERITING FROM EXPLORER.EXE? Pin
birajendu14-Apr-09 1:01
birajendu14-Apr-09 1:01 
QuestionRe: HOW TO MAKE A WIN32 APPLICATION NOT INHERITING FROM EXPLORER.EXE? Pin
David Crow14-Apr-09 3:15
David Crow14-Apr-09 3:15 
QuestionPropertySheet Pin
john563213-Apr-09 19:39
john563213-Apr-09 19:39 
AnswerRe: PropertySheet Pin
_AnsHUMAN_ 13-Apr-09 20:24
_AnsHUMAN_ 13-Apr-09 20:24 
Questionhow to get text(caption) associated with IDs in MFC dialog based application? Pin
Purish Dwivedi13-Apr-09 19:31
Purish Dwivedi13-Apr-09 19:31 
AnswerRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
_AnsHUMAN_ 13-Apr-09 20:16
_AnsHUMAN_ 13-Apr-09 20:16 
GeneralRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
Purish Dwivedi13-Apr-09 20:26
Purish Dwivedi13-Apr-09 20:26 
AnswerRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
Divyang Mithaiwala13-Apr-09 20:47
Divyang Mithaiwala13-Apr-09 20:47 
GeneralRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
Purish Dwivedi13-Apr-09 20:52
Purish Dwivedi13-Apr-09 20:52 
QuestionRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
Purish Dwivedi13-Apr-09 23:35
Purish Dwivedi13-Apr-09 23:35 
GeneralRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
Divyang Mithaiwala14-Apr-09 0:24
Divyang Mithaiwala14-Apr-09 0:24 
QuestionRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
David Crow14-Apr-09 3:17
David Crow14-Apr-09 3:17 
QuestionUpdate data in CEDB using C++ and win32 APIs Pin
vijaywithu13-Apr-09 19:00
vijaywithu13-Apr-09 19:00 
QuestionC++ win32 console copy files problems Pin
h2_goh13-Apr-09 17:44
h2_goh13-Apr-09 17:44 
I am writing the simple copy files console.
And i am getting the error:
error C2664: 'CreateFileA' : cannot convert parameter 1 from 'std::basic_string<elem,_traits,_ax>' to 'LPCSTR'

#include <windows.h>
#include <iostream>
#include <string>

using namespace std;
const int BUF_SIZE = 1024;

int main(int argc, char *argv[])
{
HANDLE fileIn, fileOut;
char buf[BUF_SIZE];

DWORD nread,nwrote;
string folder1 = "C:\\firstFolder\\";
string folder2 = "C:\\secondFolder\\";

string folder[] = {folder1, folder2};
int count=0;

for (int i = 0; i < 2; i++)
{
// copy files
if ((fileIn = CreateFile("1.doc", GENERIC_READ,0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening source: " << GetLastError() << endl;
}

if ((fileOut = CreateFile(folder[i] + "new.doc", GENERIC_WRITE,0, 0, CREATE_NEW, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening destination: " << GetLastError() << endl;
}
while (ReadFile(fileIn, buf, BUF_SIZE,&nread, NULL) && nread > 0) {
if ( ! WriteFile(fileOut, buf, nread,&nwrote, NULL)) {
cerr << "Error copy" << GetLastError() << endl;
}
}
CloseHandle(fileIn);
CloseHandle(fileOut);

// copy files
if ((fileIn = CreateFile("2.doc", GENERIC_READ,0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening source: " << GetLastError() << endl;
}

if ((fileOut = CreateFile(folder[i] + "new2.doc", GENERIC_WRITE,0, 0, CREATE_NEW, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening destination: " << GetLastError() << endl;
}
while (ReadFile(fileIn, buf, BUF_SIZE,&nread, NULL) && nread > 0) {
if ( ! WriteFile(fileOut, buf, nread,&nwrote, NULL)) {
cerr << "Error copy" << GetLastError() << endl;
}
}
CloseHandle(fileIn);
CloseHandle(fileOut);
}
return 0;
}

Does any one know how to solve the error?
Pls show me a example code if possible, thanks.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.