|
Hi Prasad,
Selecting multi-threaded - /MT - solved the problem in release (a stock console application selects single threaded).
Jeff
|
|
|
|
|
Hi,
can any one help me in upgrading my VC++ SP4 to SP6.can it be freely downloaded from NET?
mpk1979
|
|
|
|
|
|
How can i convert the above?
Thanks
|
|
|
|
|
You mean CString to TCHAR* , isn't it ?
|
|
|
|
|
No,i have to convert a Cstring variable to TCHAR variable only.No pointer for TCHAR.
|
|
|
|
|
Have you considered fact , that CString is a 'string' , array of characters ? In other words its array of TCHAR . Do you want signle TCHAR out of CString ? If yes, then reply by Navin suffice.
But seems strange wording.
|
|
|
|
|
CString cs = "some text";
TCHAR c = cs[0];
nave
|
|
|
|
|
I got it.Thanks both of you.
|
|
|
|
|
radhika28 wrote: I got it.Thanks both of you.
What was your problem? What you got?
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
radhika28 wrote: How can i convert the above?
is your application UNICODE enabled
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
hi..
try this out... TEXT("string");
|
|
|
|
|
Having just discovered that as from the February 2005 DirectX SDK, the D3DX_##.dll must be installed on the target machine and static linking is no longer an option.
Considering I am only using one function from the library 'D3DXCreateTextureFromFileEx ' Why should I add megabytes to my app? So I figure it's better to roll my own and leave D3DX out altogether.
From reading the docs, I figure I can create an IDirect3DTexture9 by calling IDirect3DDevice9::CreateTexture , I can load the texture using OleLoadPicture into an IPicture instance, but how do you copy between the two? From what I can see, the only method is to copy the bits while performing a color conversion on each pixel. Is there an easier way?
|
|
|
|
|
I guess not...
Well I have put together my own D3DXCreateTextureFromFileEx function which does more or less the same thing. I ended up having to copy the bits over since I wanted to make use of a transparent color.
|
|
|
|
|
I have one piece of code that opens a text file and returns a HANDLE to it (The actual open operation is done by c# code and the HANDLE is returned via an IntPtr).
I have another bit of code that takes a FILE* type and writes text to it using fprintf(). Is it possible to convert the HANDLE to a FILE* to pass to this bit of code?
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
Maybe _open_osfhandle() will do what you want? It returns an integer descriptor, not a FILE* , but at least it's something you can use with other CRT functions.
|
|
|
|
|
Thanks Michael
The solution was to use
int fd = _open_osfhandle((intptr_t)myHandle, _O_TEXT);
FILE * f = _fdopen(fd, "ac");
Now I can have c# client apps writting to the same log file as existing c++ libraries without modifying the existing c++ logging code
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
This[^] article is very helpful in this regard.
|
|
|
|
|
is there any zip format using checksum MD5, not CRC32?
or, any idea to compare between MD5 and CRC32????
plz help!
|
|
|
|
|
MD5 is a hash algorithm, which means it does not contain enough info to turn back in to the original data. CRC32 is, I believe, the same. There is therefore no way I can see that you could compare the two. I also don't know of any zip format that uses MD5.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
yeah.
thanks for reply. i just trying to find another way...
|
|
|
|
|
|
Alright, school is up back to the IOCP server
Everything works near to fine now, thanks to the good help i got from this site.
Anyways, there is one small problem/bug/design flaw left. I currently found a way around it but i dont like having ugly code with a way uglier solution.
Ok again im still using the IOCP with UDP.
Anyways, The problem is that i get trash in my completion ports. for example, i send something which goes fine by the way. After that i do a WSARecvFrom. Then i retrieve a IOCP notification pointing to the right extended overlapped. Now, the data inside is somethimes the right data i expected to recieve with the right size like 600 bytes, but somethimes it returns a size of 1 and no data unless i give it some time. So what do i do, i just continue and recieve a next notificication when recieving 1. this next notification contains the right data + size, so my first question, why did i get notified about my recv request before he comepletely recieved the data. a second problem, whenever i had the right data, it notifies me for like 2 extra times about it before nocking it off.
Anyone knows a NICE way to prevent this because its really ugly.
Thanks already!
|
|
|
|
|
Can you show the code you are using to look at the send completion packets - from the
GetQueuedCompletionStatus() call on?
If it truly returned indicating one byte received then you'd have to keep that one byte and
repost the recv for the remaining bytes. This doesn't make sense for UDP though, unless your
buffer sizes are messed up when you call WSARecvFrom().
|
|
|
|
|
i stripped the functions in the main code so its easier to read. this is what happends. i got a list of virtual sessions, every virtual session can be used once at a time (logical) as soon as a virtual session is released, at will be reset to another host and a post the the IOCP will be made with the task set to Begin. I've checked and counted. it one virtual session, the enum will be set to Begin and a post will be made, then he calls the member function RetrieveServerInfo which sets the buffers associated with the virtual session only, set the enum to RequestSend which sends the data. this happends one time, then it goes to after send and then the request send. till now all those steps have been held 1 time per session. After that he goes to afterrecieve. this step he repeates for a few time, even if the session is released. it might be that i use the same session AND OVERLAPPED structure for the new server query.
while (pThis->m_bKeepAlive){ <br />
BOOL bIORet = GetQueuedCompletionStatus (
pThis->m_hIOCompiltionPort,<br />
&dwIoSize,<br />
reinterpret_cast<LPDWORD>(pThis),<br />
&ptrOverlapped, INFINITE);<br />
ptrOverlappedPlus = reinterpret_cast<_OVERLAPPEDVirtualSession*>(ptrOverlapped);<br />
ptrSession = ptrOverlappedPlus->pClientContext;<br />
<br />
if (!bIORet){<br />
__REPORT("Winsock error code: %i\n", GetLastError());<br />
Gameye::Library::Thread::CMPThread::Sleep(0);<br />
}<br />
else{<br />
CAbstractServerClass* ptrGameClass = (*pThis->m_ptrGameManager)[ptrSession->getNDServer()->GameID];<br />
if (ptrGameClass == NULL){<br />
__REPORT("Game is unknown, probably removed");<br />
}<br />
else{<br />
objToolset.Session = ptrSession;<br />
switch(ptrSession->getTask()){<br />
case Begin:
pThis->m_objAddGameToolset.Session = ptrSession;<br />
ptrGameClass->RequestServerInfo(ptrSession->getNDServer(), &pThis->m_objAddGameToolset);<br />
break;<br />
case RequestSend:
dwIoSize = 0;<br />
iTemp = 0;<br />
ptrSession->setStatus(AfterSend); <br />
if (WSASendTo(ptrSession->getSocket(), <br />
ptrSession->getWSABuffer(),<br />
1,<br />
&dwIoSize,<br />
0,reinterpret_cast<sockaddr*>(ptrSession->getAddress()),<br />
sizeof(sockaddr_in),<br />
ptrSession->getOverlapped(), NULL) == -1)<br />
{<br />
int iErrorCode = WSAGetLastError();<br />
if (iErrorCode == ERROR_IO_PENDING){<br />
break;<br />
}<br />
else{<br />
__REPORT("Recieving failed because: %i", WSAGetLastError());<br />
pThis->ReleaseSession(ptrSession);<br />
}<br />
}<br />
case AfterSend:
if (dwIoSize <= 1)<br />
break;<br />
<br />
ptrSession->incSendBytes(dwIoSize);<br />
if (ptrGameClass->RetrieveServerInfo(ptrSession->getNDServer(), &objToolset) < 0){<br />
__REPORT("%s->RetrieveServerInfo() failed", ptrGameClass->Gamename());<br />
pThis->ReleaseSession(ptrSession);<br />
}<br />
break;<br />
case RequestRecieve:
dwIoSize = 0;<br />
iTemp = 0;<br />
ptrSession->setStatus(AfterRecieve);<br />
if (WSARecvFrom(ptrSession->getSocket(), <br />
ptrSession->getWSABuffer(),<br />
1,<br />
&dwIoSize,<br />
&iTemp,reinterpret_cast<sockaddr*>(ptrSession->getAddress()),<br />
&iSockAddrSize,<br />
ptrSession->getOverlapped(), NULL) == -1)<br />
{<br />
int iErrorCode = WSAGetLastError();<br />
if (iErrorCode == ERROR_IO_PENDING){ <br />
break;<br />
}<br />
else{<br />
__REPORT("Recieving failed because: %i", WSAGetLastError());<br />
pThis->ReleaseSession(ptrSession); <br />
}<br />
}<br />
case AfterRecieve:
if (dwIoSize == 1)<br />
break;<br />
ptrSession->incRecvBytes(dwIoSize);<br />
if ((iTemp = ptrGameClass->UnpackServerInfo(ptrSession->getNDServer(), &objToolset)) == 0){
pThis->FinishGame(ptrSession->getNDServer());<br />
}<br />
else if (iTemp > 0){
break;<br />
}<br />
else if (iTemp < 0){<br />
__REPORT("%s->UnpackServerInfo() failed", ptrGameClass->Gamename());<br />
}<br />
pThis->ReleaseSession(ptrSession);<br />
break;<br />
default:<br />
break;
}<br />
}<br />
}
|
|
|
|