|
akshay.is.gr8 wrote: please give me some code examples
list of rants
- This forum doesn't work that way.
- There's an article search engine, here at CodeProject[^].
- There's your best friend, Google [^].
- Microsoft kindly expose documentation online [^].
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I want to know how to display name of selected file. If user seelcted any file (test.doc) in windows explorer is there any way my application can find out the selected file name.
Thanks
jhghjghj
|
|
|
|
|
I think this[^] will help you.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Thanks for your reply.
I am using VC++ 6.0 and need code developed in VC++ 6.0. Can you pls provide the demo source code that you may have developed for VC++ 6.0. Because the urls that you provided requires to download Windows® Server 2003 SP1 Platform SDK, which is currently not possible from this end.
Or is it mandatory that any one of (Windows® Server 2003 SP1 Platform SDK / Windows® Server 2003 SP1 Platform SDK Full Download) these download needs to be install on my m/c to compile the demo code that provided.
Thanks
SNI
jhghjghj
|
|
|
|
|
You should better post those questions on the message boards of the article itself.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Please help me.....
my sectionname is same as the name entered....
my code:
void CFileINIDlg::OnBnClickedInsert()
{
const CString szINIFILE = ("C:\\FileINI.ini");
//Accept name , address and phone no from edit box
m_Name.GetWindowText(Name);
m_Ad.GetWindowText(Address);
m_Phone.GetWindowText(Phoneno);
CT2A sectn = Name;
int cmp;
int cmpflag=0;
char message[4096];
strcpy (message, "Entries :\n\n"); //Initialize
LPTSTR lpszReturnBuffer;
lpszReturnBuffer = new TCHAR[MAX_PATH];
char* pNextSection = NULL;
GetPrivateProfileSectionNames(lpszReturnBuffer,MAX_PATH,szINIFILE);
pNextSection = lpszReturnBuffer;
strcat(message, pNextSection);
while (*pNextSection != NULL)
{
//to avoid overwriting entries with same section name
cmp = _stricmp(sectn, pNextSection);
if(cmp==0)
cmpflag= 1;
else
cmpflag=0;
pNextSection = pNextSection + strle(pNextSection) + 1;
if(*pNextSection != NULL)
{
strcat(message, "\n");
strcat(message, pNextSection);
}
}
sprintf(message,"%s\n CMP %d\n FLAG %d \n", message, cmp, cmpflag);
MessageBox(message);
if(cmpflag==1)
MessageBox("ERROR - DUPLICATE");
else if(cmpflag==0)
{
WritePrivateProfileString(Name, "Name", Name, szINIFILE);
WritePrivateProfileString(Name, "Address", Address, szINIFILE);
WritePrivateProfileString(Name, "Phone", Phoneno, szINIFILE);
}
}
Im writing the values entered to the INI file.....
I want to prevent overwritng an entry ...that has
the same section name.......
if sectionname is same....i reject the entries insertion to INI file...
my code compiles.....
but strcmp() is not working.....
it always returns 1.....
how do i correct it?
modified on Wednesday, November 5, 2008 3:35 AM
|
|
|
|
|
Use your debugger and check the contents of the strings.
BTW, if you need to post code, please use the code tags, it makes your code much more readable (check also the posting guidelines at the top of this forum).
|
|
|
|
|
- Use the
code block button to surround your code snippet with <pre> tags, this way your code will be more readable. - There's a logic flaw in your while loop, you should:
- initialize
cmpflag (i.e. cmpflag=0; ) before the while loop begins. - set
cmpflag=1; whenever you find a matching entry (and optionally use the break; statement to skip the loop, since there's no need for further comparison).
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks....
i had initialized the flag...
but i dint give break.....
.....that was the ERROR
|
|
|
|
|
Well, the break statement hides the logic flaw, giving actually the correct result. Anyway, if you move the inizialization cmpflag=0; outside the while loop and don't use the break statement, your code will still work fine, but is somewhat inefficient.
YOu should note that you're searching for a matching entry and if you find it, no matter how many different entries there are, cmpflag should remain 1 .
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi. I'm working on a winsock2 program, chat program, that uses threads. The purpose of this program is to allow the user to either join a room by typing one's hostname or host a room. There are two functions that I'm using as threads: handleConnectionsThread and receiveMsgThread. These threads are used by the _beginthread() function. The handleConnectionsThread function listens and accepts incoming connections. The receiveMsgThread function receives messages that are sent by client/host. The main thread (the main program) is the thread that sends messages only. How can I use threading for this program to send/receive messages in a parallel form.
|
|
|
|
|
yamaki308 wrote: There are two functions that I'm using as threads
So where's the problem? You say you already have code that uses threads.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Here is the receiveMsgThread function
void _cdecl receiveMsgThread(LPVOID lpParam)
{
int len = 0, n = 0;
SOCKET *pSock = (SOCKET *)lpParam;
char *t_buffer = new char[BUFFER_LEN];
memset(t_buffer, 0, BUFFER_LEN * sizeof(char));
char *pBuffer = t_buffer;
n = recv(*pSock, pBuffer, sizeof(t_buffer), 0);
if(n > 0)
{
len = (int)pBuffer[0] + 1;
do
{
pBuffer += n;
len -= n;
n = recv(*pSock, pBuffer, n, 0);
}while(len > 0);
std::cout<<&t_buffer[1]<<"\n";
}
if(t_buffer)delete []t_buffer;
t_buffer = NULL;
_endthread();
}
here is the code snippet for the runClient function that receives messages while the client sends messages to the host.
while(!done)
{
_beginthread(receiveMsgThread, 0, &hSocket);
if(_kbhit())
{
memset(msg_buffer, 0, MSG_LEN * sizeof(char));
std::cout<<MSG_PROMPT;
inputString(msg_buffer, MSG_LEN);
std::cout<<"\n";
if(strcmp(msg_buffer, "\\goodbye") == 0)
done = !done;
else
{
memset(buffer, 0, BUFFER_LEN * sizeof(char));
strcpy(&buffer[1], usrName);
strcat(&buffer[1], " says, \"");
strcat(&buffer[1], msg_buffer);
strcat(&buffer[1], "\"");
buffer[0] = (char)strlen(&buffer[1]);
send(hSocket, buffer, (int)strlen(buffer), 0);
}
}
}
The problem is this: when the client sends a message it calls the _beginthread() function which calls the receiveMsgThread() function to keep the thread alive. The receiveMsgThread function gets the message until the loop breaks at (len > 0) where len == 0. When len == 0 it calls the recv function one last time and it blocks until I, the client, close the program. If I close the program, the host gets the message that has been received. It does the same thing for host when sending messages. The entire program works as far as creating sockets, connecting to the host, and such, but the problem IS the receiveMsgThread() function. Is there a way to fix this?
|
|
|
|
|
yamaki308 wrote: when the client sends a message it calls the _beginthread() function which calls the receiveMsgThread() function to keep the thread alive. The receiveMsgThread function gets the message until the loop breaks at (len > 0) where len == 0. When len == 0 it calls the recv function one last time and it blocks until I, the client, close the program. If I close the program, the host gets the message that has been received. It does the same thing for host when sending messages
Here you're describing what it does, without saying whether it is or is not the expected behavior.
yamaki308 wrote: The entire program works as far as creating sockets, connecting to the host, and such
So, where is the problem?
yamaki308 wrote: but the problem IS the receiveMsgThread() function
But what is it that receiveMsgThread() does wrong? Could you explain in what way exactly does it not do what it is supposed to do? Just pointing where the problem is isn't very helpful.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
hello everyone
Can someone give me a C code of Hausdorff-Based Image Comparison.
i have visited the link (http://www.cs.cornell.edu/Vision/hausdorff/hausmatch.html)but the link for the code is broken.
So can someone give me the code to use it.
Your Sincerely
Kaushal Kishore Sharma
Kaushal
|
|
|
|
|
I just googled and got this[^] link.
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
Hi All
How can i write text in pdf file?Pls help me
|
|
|
|
|
Does this[^] help?
Regards,
Sandip.
|
|
|
|
|
Hi all,
How to read data from a csv file in MFC C++ and display in excel format?
Thank You
|
|
|
|
|
Haven't you asked the same question 3-4 time already? Did you try suggestions given previously?
-Saurabh
|
|
|
|
|
i did try them links guided me in creating a csv file rather than reading an existing one as my question was not precise so i reposted sorry for that and some other links were obsolete sorry for the trouble.
|
|
|
|
|
Saurabh.Garg wrote: Haven't you asked the same question 3-4 time already? Did you try suggestions given previously?
Yeah first for write then for read.
|
|
|
|
|
using CStdioFile, read comma separated csv file and using OFFICE( Excel) object create the excel file from it..
Microsoft excel, can display csv file in itself!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
It looks like you've had help in reading a CSV file already.
But what do you mean by "display in excel format".
If you really want to display in excel format, have you tried using excel?
Or you could use one of the grid controls on this website?
I like http://www.codeproject.com/KB/miscctrl/gridctrl.aspx[^] myself, and use it quite a lot. But it's not a spreadsheet. It won't do any calculations for you.
Iain.
|
|
|
|
|
See here.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|