|
NewVC++ wrote: Drive Letter size?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Drive letters are generally 1 big.
If you want to know the size of a drive (whether USB or not), the GetDiskFreeSpaceEx should help you.
And GetDriveType helps you a bit to find out the (shockingly) drive type.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
you mean the hight or width of USB drive letter.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
No dear _$h@nky_
His/her answer is GetDiskFreeSpaceEx .
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hey,
I'm trying to make a server and a client application. I'm having a problem tho. I set up an async server and an async client, then have the client to connect to the server, this part works. Once I receive the FD_ACCEPT message I call accept(wParam, NULL, NULL) to accept the connection, but this is where the problem occurs. The client doesn't receive the FD_CONNECT message and I can't for the life of me figure out why.
INT_PTR CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case INCOMING_TRAFFIC:
{
switch (WSAGETSELECTEVENT(lParam))
{
case FD_CONNECT:
{
MessageBox(0, "Connected", "", 0);
const char * SendMsg = "Send message...";
send(wParam, SendMsg, strlen(SendMsg), 0);
} break;
case FD_READ:
{
char buffer[19671] = {0};
recv (wParam, buffer, sizeof(buffer)-1, 0);
MessageBox(hwnd, buffer, "Captured Text…", MB_OK);
}break;
case FD_CLOSE:
{
MessageBox(0, "Connection lost...", "", 0);
closesocket(wParam);
WSACleanup();
exit(1);
} break;
}
} break;
default:
return false;
}
return true;
}
That's the message thread for the client, it does receive messages (when I disconnect the server it receives the FD_CLOSE message), but it's not receiving FD_CONNECT. I'd appreciate some help, I can post more code if you need it.
|
|
|
|
|
I presume you correctly asked to receive connect messages in your WSAAsyncSelect call?
One tangential thing - I've seen sites suggest that this form of asynchronous socket isn't great, as it depends on the window's message queue, and high traffic rates can be problematic. Overlapped IO - initiated by setting the WSA_FLAG_OVERLAPPED flag in your WSASocket call - is suggested as a better alternative for asynchronous socket IO.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm new to sockets, I don't really get what you mean, sorry.
|
|
|
|
|
Which bit don't you understand?
If it's the bit about WSAAsyncSelect, then I'm saying that in your call to WSAAsyncSelect (which you must have, to make the socket non-blocking), the fourth parameter is a bitmask that specifies the socket events you want to receive.
If it's the second bit, about overlapped IO - never mind, forget I ever mention it
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I want to create a temp file do some process and delete it.
I've create a temp file like this.
szTempFile = new TCHAR[MAX_PATH];<br />
<br />
if(!::GetTempFileName(".","temp",0,szTempFile))<br />
{<br />
return -1;<br />
}
It's creating a temp file on the current working folder.
Then I try to delete the file as follows.
<br />
if(szTempFile != NULL)<br />
{<br />
HRESULT b = ::DeleteFile(szTempFile);<br />
}<br />
This not delete the file. When I check the path it's valid but the result of parameter b is 0.
Can someone help me to find the error.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Call GetLastError after DeleteFile and check what it returns.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Yes, I got the error code as 32.
I'm mess with the finding what it means.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
It means the file is in use.
You can delete the file only after it is closed using CloseHandle .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Can you bit explain how to use a handle for the file. I just use TCHAR buffer to hold the path. I hope your clear with my previous code segment.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
What are you doing after creating the temporary file?
Are you opening it using fopen or CreateFile ?
What operations are you doing with the file?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I read that you're using SHCreateStreamOnFile to open the file.
So you must call pOutFileStream->Release() before you can call DeleteFile .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Yes I've already close the stream before delete the file.
What I'm doing is, create a temp file, then write some data to it. And then read the content into ostream and use that stream for processing. I want to delete the temp file.
When I check the temp file path it's on working folder, like this.
.\ad.tmp
It wont be a case right?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Thanks a lot my friends.
I've solve my problem. Actually I didn't properly close one of stream handler in the process.
Thanks again.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
You might not closing the file properly.
- ns ami -
|
|
|
|
|
As Superman says, closing the file? Can you please explain a bit more how to do it. Actually I don't have handler to the file, in my code posted before.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
How is the file opened (or used)?
- ns ami -
|
|
|
|
|
I use SHCreateStreamOnFile stream on the file. Something like this.
if (FAILED(hr = SHCreateStreamOnFile(szTempFile, STGM_CREATE | STGM_WRITE, &pOutFileStream)))
I appreciate your help all the time...
CodingLover
|
|
|
|
|
That stream creation call will be opening the file.
Then you'll need to make sure you call
pOutFileStream->Release ()
at a convenient moment.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
|
I have an application which uses the win API GetShortPathName to get the short path from a long path[read from registry].
The string is terminated with a '\'. Yet the path returned is not a short path. I do not have access to the machine. What could be the reasons for this. Is there any association with the registry key NtfsDisable8dot3.
|
|
|
|
|
Hi,
How to open command prompt for spacific folder?
|
|
|
|