|
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?
|
|
|
|
|
I do this by adding a new menu item in the right click menu in windows explorer.
Create the following registry key.
HKEY_CLASSES_ROOT\Folder\shell\Command Prompt\command
Set C:\Windows\System32\Cmd.exe as the Default value.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Use create process, specify a working folder which will be the starting folder for command prompt...
void OpenCmdInDir( LPCTSTR lpctszDir )
{
STARTUPINFO StrInf = { 0 };
StrInf.cb = sizeof( StrInf );
PROCESS_INFORMATION pi = { 0 };
VERIFY( CreateProcess( NULL, "C:\\Windows\\system32\\cmd.exe", NULL, NULL, FALSE, 0, 0, lpctszDir, &StrInf, &pi ));
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
OpenCmdInDir( _T( "C:\\Windows\\System32\\Drivers" ));
|
|
|
|
|
I have used createProcess to run a process in a new window using CREATE_NEW_CONSOLE flag,
Can any one help to get the handle to the console that i have created so as to close that window.
code:
CreateProcess(_T("\\windows\\ceplayer.exe"),_T("c:\\folder\\new.wmv"), NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, NULL, &processInfo);
Thanks in Advance
|
|
|
|
|
You can use EnumWindows() or EnumThreadWindows() to enumerate top level windows and GetWindowThreadProcessid() to check if specific window is created by your process (processInfo.dwProceddId)
Slavisa
|
|
|
|
|
Thanks Slavisa,
I tried it. but it does nothing i donno why..
Could u please help me further with my code below:
(I want to close the console that created within 3 seconds but it is not moving into that if part (bold))
CreateProcess(_T("\\windows\\iesample.exe"),imFullPath, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, NULL, &processInfo1);
Sleep(3000);
EnumWindows(&EnumProc,processInfo1.dwProcessId);
BOOL CALLBACK EnumProc(HWND hwnd, LPARAM param)
{
DWORD id = GetWindowThreadProcessId(hwnd, NULL);
if (id == (DWORD)param)
{
DestroyWindow(hwnd);
return false;
}
return true;
}
|
|
|
|
|
The return value of GetWindowThreadProcessId is the thread Id and not the process Id.
If you want the process Id, use the second parameter like so.
DWORD dwProcessId = 0;
GetWindowThreadProcessId(hwnd, &dwProcessId);
if (dwProcessId == (DWORD)param)
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Friens i used
GetWindowThreadProcessId(hwnd, &dwProcessId);
and also PostMessage(hwnd,WM_CLOSE,0);
but it is not moving into that if loop still
if(dwprocessid == DWORD(param))
i could not figure it out what i need to do now or IS there any other way to get the handle of the window
seeking ur help....
|
|
|
|