|
You still do not need to allocate a buffer, since all you need is a pointer to a single character.
Hmmm! I should have noted that recv(server,...) was a typo, since that was a typo, then shutdown(server...) is also a typo.
I looked up the functions used and here is what your code will do once the typos are fix:
FIRST TIME TRU LOOP:
1) Read 1 byte from the socket and then ignore it.
2) START INFINITE LOOP {
3) Open a file.
4) While( there is a byte received OR a SOCKET_ERROR ) {
5) copy byte to file. // before checking if error occured
6) if( error )
break;
}
7) Shut down socket so you can no longer send or receive and data.
(This means recv(...) will now always return SOCKET_ERROR)
8) Close file.
9) } // END OF INFINITE LOOP
AFTER FIRST LOOP:
1) START INFINITE LOOP {
2) Open file.
3) While( SOCKET_ERROR ) { // because of shutdown above
4) Write the last character received (during first loop).
5) Break out of loop (since it was a SOCKER_ERROR).
}
6) Try to shut down again (cann't because it was already done).
7) Close file.
8) } // END OF INFINITE LOOP
I do not think that was what you were trying to do, but that is what should be happening. There is also the fact that the INFINITE LOOP cann't be stoped properly (any other way if bad).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi Everybody,
I need some help. I would like to program a small tool like the Win.Task Manager which is able to show all running Threads and also the Virtual Memory which is in use... There should be an funktion for getting al the nessecary Informations but i can't find it. Hope some of guys can help me with some Ideas or maybe someone has already that kinda tool. Would be very nice of you.
|
|
|
|
|
|
I am trying to find Sourcecode for getting data from ListView Control using Win32 api.please provide me a working source code ,i know the api's ,but i am unable to use them.
any help is greatly apreciated.
Thanks
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
To work with the list view control in win32 you just SendMessage any of the LVM_* list view messages to the control. The info will either be the return value, or contained in the structures you pass in as the message parameter.
For example to get the number of items in the control:
int NumItems = SendMessage(HWNDListView, LVM_GETITEMCOUNT, 0, 0);
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks,
actually My Problem was solved yesterday only.i am trying to get List View data from a different Application through my program.May be that program hooked WM_GETTEXT ,that why every time it returning NULL.
Using DLL injection,i SOrted Out My Problem.Thanks For aBove.
PJ Arends wrote:
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Trust Me!! you are Definitely a Real SuperStar of CP
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi,
I am having a problem with updateResource API with strings.
I want to delete all the strings in a string Table and rewrite them in another language.
This creates 2 sting tables
1. the new destination string table with the new strings.
2. the older string table (All the strings are however deleted here)
on selecting the older sting table in the resource editor(VC.NET), the editor throws an error and shut down throws
I want to get rid of the older String table
PS NOTE: the application works properly in some computers but in some computers, the above mentioned problem occurs...
Could i know the reason for the same, and the process of getting rid of this problem..
thanks in advance..
Vinod
|
|
|
|
|
Hi,
I need to generate a lot of Excel files. I don't want to use Excel Automation (Excel version dependant, perf, etc. ). So, I'm looking for a good C++ library to create spreadsheets dynamically...
No C#, No .net. ActiveX would be ok. (actually, I'm using STL/ATL)
Nota:
CSV files do not match my requirements cause I have to customize cells, borders, colors and so on...
Can you help me ?
|
|
|
|
|
You distant past may still haunt you...
magicbassfr wrote: I need to generate a lot of Excel files. I don't want to use Excel Automation (Excel version dependant, perf, etc. ). So, I'm looking for a good C++ library to create spreadsheets dynamically...
I know you posted this quite some tome ago... therefore I am hoping you have found a solution as I have the same requirement... what did you end up using?
Thanks for any help...
|
|
|
|
|
i want the Imgocxd.hlp file im working on image scanning and saving it to hard disk if any one have it then pls giv me
Shahbaz kiani
|
|
|
|
|
Hi Everyboday,
While installing global message hook (WH_GETMESSAGE) on WinXP limited
user account i am getting "Access Denied" error.
The same code is working fine on Win2k machines (in any user mode)
I have written a dll in which all my global hook stuff resides, which
has some export function to install/uninstall the global hook.
Can any body please guide me what i am doing wrong here ?
Thank you,
Vishal
VM
|
|
|
|
|
Yup problem solved
Vishal
|
|
|
|
|
every body....
my code is following.
my problem is only photo2 is show.
i want to show both photo1 and photo2.plz help me...
//MyView.h
CStatic m_photo1;
CStatic m_photo2;
HBITMAP m_hBmpOld;
HBITMAP m_hBmpNew;
BITMAP m_bmInfo;
//MyView.cpp
void CMyView::OnOK()
{
Load_Photo_1("image/1.bmp");
Load_Photo_2("image/2.bmp");
}
void CMyView::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
dc.BitBlt(offsetx,offsety,m_size.cx,m_size.cy,
&m_dcMem, sourcex, sourcey,SRCCOPY);
CFormView::OnPaint();
}
}
void CMyView::OnInitialUpdate()
{
CClientDC dc(this);
m_dcMem.CreateCompatibleDC( &dc );
}
void CMyView::Load_Photo_1(CString p_filepath)
{
m_hBmpNew = (HBITMAP) LoadImage(
AfxGetInstanceHandle(),
p_filepath,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE);
if( m_hBmpNew == NULL )
{
AfxMessageBox("Load Image Failed");
}
else
{
m_photo1.GetClientRect( &rectStaticClient );
rectStaticClient.NormalizeRect();
m_size.cx=rectStaticClient.Size().cx;
m_size.cy=rectStaticClient.Size().cy;
m_size.cx = rectStaticClient.Width(); // zero based
m_size.cy = rectStaticClient.Height(); // zero based
m_photo1.ClientToScreen( &rectStaticClient );
ScreenToClient( &rectStaticClient);
m_pt.x = rectStaticClient.left;
m_pt.y = rectStaticClient.top;
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMem, m_hBmpNew));
offsetx= m_pt.x;
offsety=m_pt.y;
InvalidateRect(&rectStaticClient);
}
}
void CMyView::Load_Photo_2(CString p_filepath)
{
m_hBmpNew = (HBITMAP) LoadImage(
AfxGetInstanceHandle(),
p_filepath,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE);
if( m_hBmpNew == NULL )
{
AfxMessageBox("Load Image Failed");
}
else
{
m_photo2.GetClientRect( &rectStaticClient );
rectStaticClient.NormalizeRect();
m_size.cx=rectStaticClient.Size().cx;
m_size.cy=rectStaticClient.Size().cy;
m_size.cx = rectStaticClient.Width(); // zero based
m_size.cy = rectStaticClient.Height(); // zero based
m_photo2.ClientToScreen( &rectStaticClient );
ScreenToClient( &rectStaticClient);
m_pt.x = rectStaticClient.left;
m_pt.y = rectStaticClient.top;
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMem, m_hBmpNew));
offsetx= m_pt.x;
offsety=m_pt.y;
InvalidateRect(&rectStaticClient);
}
}
|
|
|
|
|
definitely.....only the photo2 will get loaded.....
u have defined only one dcmemory variable.....
and u have assigned both the photoz to that same dcmemory variable.....
since the first gets assigned to the "m_dcMem".....what happens is u assign even the second photo to the same variable "m_dcMem" so the first getz overwritten.....
use two seperate variables :m_dcMem1 and m_dcMem2
that should sove the prob.....
happy programmin.....
cheerz.....
|
|
|
|
|
and oh.....i forgot,therz one more thing.....
in ur paint function.....make sure u give two BitBlts.....
that iz....
dc.BitBlt(offsetx1,offsety1,m_size1.cx,m_size1.cy,&m_dcMem1, sourcex1, sourcey1,SRCCOPY);
dc.BitBlt(offsetx2,offsety2,m_size2.cx,m_size2.cy,&m_dcMem2, sourcex2, sourcey2,SRCCOPY);
i hope u got that as well.....
happy programmin.....
cheerz.....
|
|
|
|
|
i understand ...
thank you...
|
|
|
|
|
I have a socket server application that uses async sockets and a completeion port.
We have installed it at a new client site in Sydney and they have some users in London, Sydney and New York. The London users only are reporting that the client application gets disconnected from time to time. This is not reproducible using the UAT environment at the client site.
Sometimes when we call ::send() in the server SOCKET_ERROR is returned and WSAGetLastError() returns WSAEWOULDBLOCK. I believe this is because windows is still performing the last send operation on this socket.
In this case we call ::select() with the socket in the writefds param and a timeout. This code has always worked successfully in the past. What I find now is that for these London users ::select()is returning a value other than 1. Unfortunately the exact value returned is not logged by the sever. I have had the customer increase the timeout value that is passed to the ::select() call but it is still failing. Anyone got any bright ideas?
|
|
|
|
|
FWIW different socket implementations support different subsets of the select options. You might want to check if the winsock on the problem machine is the same as the others. Just a thought.
|
|
|
|
|
If i use WriteFile to write over a file with null bytes, will it actually write over the existing bytes on the drive or will it just write them to a new location on the drive.
|
|
|
|
|
It will write over the bytes
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
Yes
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
There are to threads:
//thread one:
CSingleLock m_lock(&syn_object);
m_lock.Lock();
/*
.....Doing something
*/
m_lock.UnLock();
/=================================
thread two:
CSingleLock m_lock(&syn_object);
m_lock.Lock();
while (!m_lock.IsLocked());
//continue to do something if thread one finished with thre resource
I want the thread two to wait for the thread one finished 'doing something' before continue but the whole program seems to crash here.
|
|
|
|
|
lisoft wrote:
m_lock.Lock();
while (!m_lock.IsLocked());
Your will always hang on the while line as you just locked m_lock on the previous line.
There is no need to check the lock state as the code will wait on the m_lock.Lock() line until thread one has unlocked the lock.
Remove the while and your code should work better.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Your
while (!m_lock.IsLocked());
will never execute because m_lock will always be locked at that step.
Your request cries out for a manual reset event but it looks like you are using something other than an event.
John
|
|
|
|