|
Which method are you using to get id's from the resource dll?
LoadLibrary???
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
|
Hi Purish,
Have you tried SetDlgItemText[^] & GetDlgItemText[^]?
Do not trust a computer...
Always check what computer is doing
regards,
Divyang Mithaiwala
Software Engineer
|
|
|
|
|
I am looking for the same.
Well how can I go there, I want to know the full code as I am new to it,so don't have much knowledge.
Something like AfxGetMainWnd-DlgCtrlId->
how can I do this?
Thanks..........
|
|
|
|
|
how to get those texts associated with IDs?
|
|
|
|
|
Purish Dwivedi wrote: Something like AfxGetMainWnd-DlgCtrlId->
If you are accessing Dialog item from DLL then DLL must have handle/pointer of CDialog class.
If you don't have then take one pointer of CDialog class & write one method in your DLL for setDialog(CDailog*)
So, at initialization of DLL you can specify CDialog pointer in that.
I hope this works for you.
Do not trust a computer...
Always check what computer is doing
regards,
Divyang Mithaiwala
Software Engineer
|
|
|
|
|
Are you referring to LoadString() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi i am using CEDB to access windows CE datas.. Now i need to update the datas in CEDB.
code:
oid=CeSeekDatabaseEx(globalHDB,CEDB_SEEK_BEGINNING,seekcount,NULL,NULL);
I use it to seek in database for each cases i uses
case 0:
epropColumn[0].propid = CID_BOOKID;
cepropColumn[0].val.lpwstr=szBookID;
cepropColumn[0].wFlags = NULL;
cepropColumn[0].wLenData = 0;
to get the column values i use these cases for each column of the row.
Can any one help me to change only one value in the row.
for example
if i hav book id,book_name,author.
say
bk001,C++,martin
i need it to be changed as
bk001,Java,martin
A code snippet would be help ful.
Help me to trace it out.
Thanks in Advance.
|
|
|
|
|
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.
|
|
|
|
|
you can do it like this
CreateFile(_T("1.doc"), GENERIC_READ,0, 0, OPEN_EXISTING, 0, 0)
|
|
|
|
|
This line of code doesn't has error,
CreateFile("1.doc", GENERIC_READ,0, 0, OPEN_EXISTING, 0, 0)
My error code is here,
fileOut = CreateFile(folder[i] + "new.doc", GENERIC_WRITE,0, 0, CREATE_NEW, 0, 0)
I cannot write the string into the parameter 1 with only allow 'LPCSTR', and i tried to convert it, but i getting another error:
CXX0052: Error: member function not present
string path;
path = folder[i] + "new.doc";
fileOut = CreateFile(path.c_str(),GENERIC_WRITE,0, 0, CREATE_NEW, 0, 0);
any idea? thanks..
|
|
|
|
|
// test01.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#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;
wstring folder1 = L"C:\\firstFolder\\";
wstring folder2 = L"C:\\secondFolder\\";
wstring file1 =L"1.doc";
wstring file2=L"new.doc";
wstring file3=L"2.doc";
wstring file4=L"new2.doc";
wstring folder[] = {folder1, folder2};
int count=0;
for (int i = 0; i < 2; i++)
{
// copy files
if ((fileIn = CreateFile(file1.c_str(), GENERIC_READ,0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening source: " << GetLastError() << endl;
}
if ((fileOut = CreateFile((folder[i] + file2).c_str(), 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(file3.c_str(), GENERIC_READ,0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening source: " << GetLastError() << endl;
}
if ((fileOut = CreateFile((folder[i] + file4).c_str(), 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;
}
|
|
|
|
|
You are misusing the string class. Read the docs
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: You are misusing the string class. Read the docs
Ah, but string deserves it. It said bad things about his mother.
But I'm not a huge fan of string for this reason. I quite like CString's implicit LPCTSTR conversion.
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Hi I have an assignment to write a simple phone book program. I've done that & everything is working perfectly except my edit function. Can someone plz help me. Here is what I've done so far (sorry it's so long):
/*
Name: Subrina's Phone Book
Author: Subrina Bisnauth
Description: Electronic phone book
*/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
void menu();
void program_start();
void add();
void edit();
void search();
void del();
void view();
void program_exit();
void DelayProg(float sec);
char name[100];
char email[50];
char phone[15];
char namebuff[50];
char lnamebuff[50];
char buf[80];
int count;
FILE *phonebook;
FILE *pbtemp;
time_t now;
struct tm *ts;
/*Main Function*/
int main()
{
system("CLS");
program_start();
menu ();
view();
return 0;
}
/*Menu Function*/
void menu()
{
int ch = 0;
char ch2;
program_start();
printf("\t\t Please choose one . . .\n\n");
printf("\t\t\t1: < Add to phonebook >\n");
printf("\t\t\t2: < Edit phonebook >\n");
printf("\t\t\t3: < Search phonebook >\n");
printf("\t\t\t4: < Remove from phonebook >\n");
printf("\t\t\t5: < View phonebook >\n");
printf("\t\t\t6: < Exit phonebook >\n\n");
printf("\t\t\t\tPlease enter the number of your choice: ");
fflush(stdin);
scanf("%d", &ch);
switch(ch)
{
case 1:
add();
case 2:
edit();
case 3:
search();
case 4:
del();
case 5:
view();
case 6:
program_exit();
default:
program_start();
printf("\t\tYou must choose 1 - 5. Retry? Y/N ");
fflush(stdin);
scanf("%c", &ch2);
if(ch2=='y'||ch2=='Y')
{
menu();
}
else
{
program_exit();
}
}
}
/*Function executed at program start-up*/
void program_start()
{
system("CLS");
FILE *file;
}
/* Function that allows new entries to be made in the phonebook*/
void add()
{
int numbers[100];
char choice;
do {
int Exists = 0;
program_start();
printf("\t\t- Add to Phonebook -\n\n");
printf("\n\t\t\tEnter Full Name: ");
fflush(stdin);
gets(name);
strcat(name, "|");
strcat(name, "\n");
phonebook = fopen("phonebook.txt","a+");
while(!feof(phonebook) && Exists==0)
{
fgets(namebuff, 50, phonebook);
if(strcmp(name, namebuff)==0)
{
printf("\n\t\tThat entry is already stored in the phonebook . . .");
printf("\n\n\t\t\t");
system("PAUSE");
Exists=1;
}
}
if(!Exists)
{
ts = localtime(&now);
strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts);
printf("\n\t\t\tEmail : ");
gets(email);
fflush(stdin);
printf("\n\n\t\t\tPhone Number: ");
gets(phone);
fflush(stdin);
fprintf(phonebook, "%s%s\n%s\n\n%s\n%s\n", name, email, phone, buf);
}
fclose(phonebook);
program_start();
printf("If you would like to continue press Y or if you want to return to the menu press N\n ");
fflush(stdin);
scanf("%c", &choice);
if(choice!='y'&&choice!='Y')
{
menu();
}
}while(choice=='y'||choice=='Y');
}
/*Function to search for a particular entry in the phonebook*/
void search()
{
char choice;
int length;
do {
int Exists = 0;
int i = 1;
program_start();
printf("\t\t- Search phonebook -\n\n");
printf("\n\t\t\tEnter Full Name: ");
fflush(stdin);
gets(name);
strcat(name, "|");
strcat(name, "\n");
phonebook = fopen("phonebook.txt","r");
while(!feof(phonebook) && Exists==0)
{
fgets(namebuff, 50, phonebook);
if((strcmp(namebuff, name)==0))
{
Exists = 1;
while(i<6)
{
if(i==1)
{
fgets(email, 50, phonebook);
fflush(stdin);
}
if(i==5)
{
fgets(phone, 15, phonebook);
fflush(stdin);
}
i++;
}
}
}
if(Exists)
{
name[strlen(name)-2]=' ';
printf("\n\t\tSuccess . . .\n\n");
printf("\t\tName : %s\n", name);
printf("\t\tEmail : %s\n", email);
printf("\t\tPhone Number: %s\n", phone);
printf("\n\n\t\t\t");
system("PAUSE");
fflush(stdin);
}
else
{
length = strlen(name);
name[length-2] = '\0';
printf("\n\t\tSorry . . .\n\n");
printf("\t\t\"%s\" was not found in phonebook.", name);
printf("\n\n\t\t\t");
system("PAUSE");
fflush(stdin);
}
fclose(phonebook);
program_start();
printf("If you would like to continue press Y or if you want to return to the menu press N\n ");
fflush(stdin);
scanf("%c", &choice);
if(choice!='y'&&choice!='Y')
{
menu();
}
}while(choice=='y'||choice=='Y');
}
/*Function to edit entries in the phonebook*/
void edit()
{
char choice;
int length;
do {
int Exists = 0;
int i = 1;
int g;
char ph[6];
char nam[25];
char e_mail[15];
char tel[15];
program_start();
printf("\t\t- Edit an entry -\n\n");
printf("\n\t\t\tEnter Full Name: ");
fflush(stdin);
gets(name);
strcat(name, "|");
strcat(name, "\n");
phonebook = fopen("phonebook.txt","r+");
while(!feof(phonebook) && Exists==0)
{
fgets(namebuff, 50, phonebook);
if((strcmp(namebuff, name)==0))
{
Exists = 1;
while(i<6)
{
if(i==1)
{
fgets(email, 50, phonebook);
fflush(stdin);
}
if(i==5)
{
fgets(phone, 15, phonebook);
fflush(stdin);
}
i++;
}
}
}
if(Exists)
{
name[strlen(name)-2]=' ';
for (g=0;g<count;g++)
{
printf("\n\tPlease enter what you would like to edit - name, e-mail or tel");
scanf("%s", &ph);
if(ph=='name')
{
printf("\n\t\tPlease enter the correct name");
scanf("%s",&nam);
name[g]=nam;
}
if(ph=='e-mail')
{
printf("\n\t\tPlease enter the correct e-mail address");
scanf("%s",&e_mail);
email[g]=e_mail;
}
if(ph=='tel')
{
printf("\n\t\tPlease enter the correct telephone #");
scanf("%s",&tel);
phone[g]=tel;
}
}
}
else
{
length = strlen(name);
name[length-2] = '\0';
printf("\n\t\tSorry . . .\n\n");
printf("\t\t\"%s\" was not found in phonebook.", name);
printf("\n\n\t\t\t");
system("PAUSE");
fflush(stdin);
}
fclose(phonebook);
program_start();
printf("If you would like to continue press Y or if you want to return to the menu press N\n ");
fflush(stdin);
scanf("%c", &choice);
if(choice!='y'&&choice!='Y')
{
menu();
}
}while(choice=='y'||choice=='Y');
}
/*Fuction to delete entries from phonebook*/
void del()
{
char conf;
int Exist = 0;
int len;
int i = 1;
program_start();
printf("\t\t- Delete From phonebook -\n\n");
printf("\n\t\t\tEnter Full Name: ");
fflush(stdin);
gets(name);
strcat(name, "\n");
if(phonebook = fopen("phonebook.txt", "r"))
{
printf("\n\n\t\tDelete the selection? Y/N ");
scanf("%c", &conf);
if(conf=='y'||conf=='Y')
{
if(pbtemp = fopen("phonebook", "w"))
{
while(!feof(phonebook))
{
fgets(namebuff, 50, phonebook);
len = strlen(namebuff);
if(namebuff[len-2]=='|')
{
namebuff[len-2]='\n';
namebuff[len-1]='\0';
if(strcmp(name, namebuff)!=0)
{
while(i<6)
{
if(i==1)
{
fgets(email, 50, phonebook);
fflush(stdin);
}
if(i==5)
{
fgets(phone, 15, phonebook);
fflush(stdin);
}
i++;
}
namebuff[len-2]='|';
namebuff[len-1]='\n';
fprintf(pbtemp, "%s%s%s", namebuff, email, phone);
}
else if((strcmp(name, namebuff)==0))
{
Exist = 1;
}
}
}
if(!Exist)
{
fclose(pbtemp);
fclose(phonebook);
len = strlen(name);
name[len-1]='\0';
program_start();
printf("\t\t- Delete From phonebook -\n\n");
printf("\t\tSorry . . .\n\n");
printf("\t\t\"%s\" was not found in phonebook.\n\n", name);
printf("\t\t\t");
system("PAUSE");
fflush(stdin);
remove("phonebook.txt");
menu();
}
}
else
{
fclose(phonebook);
fclose(pbtemp);
program_start();
printf("\t\t- Delete From phonebook -\n\n");
printf("\t\t\tError . . .\n\n");
printf("\t\t\tThe file could not be opened.\n\n");
printf("\t\t");
system("PAUSE");
fflush(stdin);
menu();
}
fclose(pbtemp);
fclose(phonebook);
len = strlen(name);
name[len-1]='\0';
remove("phonebook.txt");
rename("pbtemp.txt", "phonebook");
program_start();
printf("\t\t- Delete From phonebook -\n\n");
printf("\t\t\t\"%s\" was deleted from phonebook.", name);
printf("\n\n\t\t");
system("PAUSE");
fflush(stdin);
view();
}
else
{
fclose(phonebook);
len = strlen(name);
name[len-1]='\0';
program_start();
printf("\t\t- Delete From phonebook -\n\n");
printf("\t\t\t\"%s\" was not deleted.", name);
printf("\n\n\t\t");
system("PAUSE");
menu();
}
}
else
{
program_start();
printf("\t\t- Delete From phonebook -\n\n");
printf("\t\t\tError . . .\n\n");
printf("\t\t\tThe file could not be opened.\n\n");
printf("\t\t");
system("PAUSE");
menu();
}
}
/*Function that allows user to view entries in phonebook*/
void view()
{
namebuff[0] = '\0';
int len;
phonebook = fopen("phonebook.txt", "r");
program_start();
printf("\t\t- View phonebook -\n\n");
while(!feof(phonebook))
{
int i = 1;
fflush(stdin);
fgets(namebuff, 50, phonebook);
len = strlen(namebuff);
if(namebuff[len-2]=='|')
{
while(i<6)
{
if(i==1)
{
fgets(email, 50, phonebook);
fflush(stdin);
}
if(i==5)
{
fgets(phone, 15, phonebook);
fflush(stdin);
}
i++;
}
namebuff[len-2]=' ';
printf("\n\t\t\tName : %s", namebuff);
printf("\n\t\t\tEmail : %s", phone);
printf("\n\t\t\tPhone Number: %s\n", phone);
}
}
printf("\n\n\t\t\t");
system("PAUSE");
fclose(phonebook);
menu();
}
/*Function executed when program is about to close*/
void program_exit()
{
fflush(stdin);
program_start();
printf("\t\t\tThank you for using phonebook . . .");
DelayProg(2);
}
/*Function that controls the time delay when program is about to exit*/
void DelayProg(float sec)
{
float t = GetTickCount() + (1000L*sec);
while(GetTickCount() < t)
{
}
exit(1);
}
/*End of Program*/
|
|
|
|
|
Subrina Bisnauth wrote: (sorry it's so long):
So then fix it. If you already know the problem is with edit() , then post just that code. All the other is just useless noise.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi All,
I am making a change to some ancient WinSock legacy code. What I am trying to do is modify the server code to have the server pass messages received from all the clients to a special “reporting client”. It appears that when I receive a message from a client and try to pass the message along to the “reporting client”, that the message is never sent (or never received by the “reporting client”). I am using the standard send() command with the socket number of the “reporting client”. Could the problem be that I’m currently in the thread to communicate with one client when I’m trying to do the send() to another? I'd appreciate any insights anyone might have. Thanks in advance.
|
|
|
|
|
Is it something like this?
Thread1: Server Listening on port A (socket 1)
Thread2-10: Client Doing stuff, sending to the server on port A from ports B-J (socket 2-10)
Thread11: Server Reporting Client listening on port I (socket 11)
I think what I read was that you're in Thread1 trying to use send() with socket 11. That won't work, you should use send() with socket 1 in Thread1.
If the threads are _sharing_ sockets, then you should have some sort of synch object to keep them from randomly failing in race conditions.
And if you have two listening threads, they should probably be on two different ports. Hope that helps.
|
|
|
|
|
Bulg,
Thanks for your reply. I think my previous explanation of the issue was lacking (I’m a complete newbie to sockets/threads [i.e., I don’t think I’m fully aware of my ignorance]). I’ll use a diagram to attempt to clarify:
Client 1
|
| Client 2
| |
V V ...
----------
| Server | ---> Reporting Client
----------
^
|
|
Client X
The standard Clients 1 through X are running tests and reporting their statuses to the Server. The Server is then passing a subset of these status messages on to the Reporting Client.
The Server sees a status message coming from one of the Clients and immediately does a send() using the socket number of the Reporting Client, but these messages are not being seen at the Reporting Client and I’m wondering if the problem is that I’m currently in the thread that is communicating with Client X when I’m trying to do a send() to the Reporting Client.
Thanks again for your help.
|
|
|
|
|
I like your diagram, I'm gonna copy it and add stuff to it
Client 1
Socket 1
|
| Client 2
| |Socket 2
| |
V V
Socket S
^ |
| V
| Server -> Socket R -----> Socket 3 -> Reporting Client
|
|
|
|
Socket X
Client X
Each listening socket must be bound (bind() ) to a port number. A process that wants to send information to a listening socket, as far as I know, must use a different socket to send information to the listening socket.
So when you say socket number, I know that sockets are returned from socket() as integers, and I know that listening sockets are bound to port numbers, also integers. Which of those two is a "socket number"?
some code:
...
if(bind(serv_sock, (struct sockaddr*)&serv_addr,sizeof(serv_addr)) < 0){
}
if(listen(serv_sock,MAXPENDING)<0){
}
for(;;) {
if((client_sock = accept(serv_sock,(struct sockaddr*)client_addr, sizeof(client_addr)) < 0){
HandleTCPClient(client_sock)
}
}
...
if(bind(serv_sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0){
}
for(;;) {
if(recv_size = recvfrom(serv_sock, buffer, MAX_BUFFER, 0, (struct sockaddr*)&client_addr, sizeof(client_addr)) < 0) {
sendto(serv_sock, buffer, recv_size, 0, (struct sockaddr*)&other_addr, sizeof(other_addr));
} I admit that the for(smileyface) may be misleading at first.
|
|
|
|
|
Bulg,
First, thanks for taking time to look into this.
The socket number I'm referring to is the socket number returned from the accept() call:
SOCKET tempSock = accept(aArgs->socket, (LPSOCKADDR)&SockAddr, &mLen);
and then passed into the send() call:
int iRet = send(ReportingClientData.CurrentSocket, dlgMessage, COMMANDSIZE, 0);
Keep in mind that this is ancient WinSock code.
|
|
|
|
|
This is just a general question looking for suggestions. I want to use Visual C++ 6.0 to create an application that will allow me to pass traffic from the internet to a special USB device I have designed. Presently I can send to and get responses from the USB device using the code development tools.
My thinking is to create an internet application on the PC side using a port above 1024. By doing that I don't have to get the remote end user to make any changes on their router. I was thinking of maybe creating something similar to a telnet server or maybe a chat client/server.
I will just be passing small commands over the internet which will then be sent out the USB port on the PC to my embedded application. The USB device will just return a "Success" or "Failure" response. Does anyone have any suggestions as what would be the best approach to this?
Thank you.
Ray
|
|
|
|
|
"internet" programming is done using "sockets". If you look them up that should give you quite a few good starting points.
|
|
|
|
|
bulg wrote: "internet" programming is done using "sockets".
Yes, I know that. I was more interested in suggestions about which type of "server" would be best for me to create to handle the incoming traffic. I know I can open a socket and retrieve the data and write it to a buffer. Once I have the data, I guess I could then pass it to the USB device. Or write it to a file and have the USB device read it in.
|
|
|
|
|
Hrmm, then I'm going to try to guess that your question could be narrowed down a little bit more:
How does a server make and keep track of multiple clients and sessions ( aka, client logs in, interacts with the system, logs out)?
|
|
|
|
|