|
Have a look at Joe Newcomer's article about worker threads. It's excellent!
He'll show you how to all of this the correct way here[^].
I urge you to read the complete article since it will make you aware of problems you have to know how to deal with when doing multithreading.
Hope this helps
--
Roger
It's suppose to be hard, otherwise anybody could do it!
|
|
|
|
|
First when you create the thread but before you let it run make sure you do the following (you will have to create it suspended):
pThread->m_bAutoDelete = FALSE;
There is no point in having a collection of CWinThread pointers if you have no way of knowing if the object pointed to has been delete or not!
Now you can wait for a thread to exit using the Win32 API as follows:
WaitForSingleObject(pThread->m_hThread, INFINITE);
Remember we've turned auto deletion off so you have to remember to delete the CWinThread objects when you're done with them - deleting one doesn't stop the thread running (if it's running).
Steve
|
|
|
|
|
how to write a logfile in the COM component
suresh
|
|
|
|
|
Use an ofstream object for that:
ofstream OutputFile("MyFile.txt");
int SomeVariable = 10;
OutputFile<<"SomeText"<<SomeVariable<<endl;
|
|
|
|
|
ok thanq
but,i want create .txt file at the server side.........
suresh
|
|
|
|
|
Which server ?? Please when asking a question be more specific. What are you trying to do exaclty ? Provide as much relevant information as possible.
|
|
|
|
|
Then give a file name to a file at the server! Example:
\\Server02\Share$\aDirectory\aTextFile.txt
|
|
|
|
|
Is there a way to do this in Windows without .neT?
Thanks!
|
|
|
|
|
BOOL CreateDirectory(
LPCTSTR lpPathName, // pointer to directory path string
LPSECURITY_ATTRIBUTES lpSecurityAttributes // pointer to security descriptor
);
BOOL RemoveDirectory(
LPCTSTR lpPathName // pointer to directory to remove
);
|
|
|
|
|
|
hi,
i have 2 variables like
char * username
char sysname[MAX_PATH]
i need to use "NetUserGetInfo" windows API method, which takes two LPCWSTR strings, how can i convert the above sysname,username to pass them to NetUserGetInfo.
thanks
|
|
|
|
|
Use A2W string conversion macro.
void func( LPSTR lpsz )
{
USES_CONVERSION;
...
LPWSTR x = A2W(lpsz)
...
}
Nibu thomas
Software Developer
|
|
|
|
|
I need exactly the reverse way,
that is i have char* username, char sysname[max_PATH].
i need to pass these 2 variables to NetUserGetInfo(LPCWSTR,LPCWSTR)
thanks
|
|
|
|
|
gbabu17 wrote: I need exactly the reverse way,
that is i have char* username, char sysname[max_PATH].
i need to pass these 2 variables to NetUserGetInfo(LPCWSTR,LPCWSTR)
Nibu thomas
Software Developer
|
|
|
|
|
Life isn't easy, isn't ?
|
|
|
|
|
if your problem is NetUserGetInfo for conversition) use (or like this)
LPTSTR user;
LPTSTR computer;
user=(LPTSTR)LocalAlloc(LPTR,256);
computer=(LPTSTR)LocalAlloc(LPTR,256);
DWORD d=256;
GetUserName(user,&d);
DWORD dd=256;
GetComputerName(computer,&dd);
wchar_t *m_User = T2W(user);
wchar_t *m_computer = T2W(computer);
DWORD dwLevel = 4;
USER_INFO_2 *m_Userinfo;
DWORD dddd=NetUserGetInfo(m_computer, m_User , 2, (LPBYTE*)&m_Userinfo);
|
|
|
|
|
Which is what A2W() does. I've done it this way in the past:
LPUSER_INFO_2 pUserInfo = NULL;
CString strUser;
NET_API_STATUS nStatus = NetUserGetInfo(L"\\\\server", A2W(strUser), 2, (LPBYTE *) &pUserInfo);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
I have faced this question in an interview,
Design algorithm for elevators using any design pattern.
please guide me regarding this.
krishna
|
|
|
|
|
Well I can give a brief description
When they go up they keep going up processing the requests on the way.
and
When they come down they keep coming down processing the requests on the way.
They don't change direction in between unless they have processed all requests in that direction
and
BTW if anybody gives another request before it changes direction it processes that too.
This is called the elevator algorithm.
Nibu thomas
Software Developer
|
|
|
|
|
hai,
can u elaborate this , just like what r the abstract base class we r designing for this and derived classes and some importnt methods.
|
|
|
|
|
Composite Pattern - For the structure, components and movement of the elevator (e.g. doors, switches, lightsource etc.).
Iterator Pattern - For the list of floors.
Observer Pattern - To identify on which floor to stop.
Rahim Rattani
Software Engineer,
Matrix Systems (Pvt) Ltd.,
Karachi - Pakistan
|
|
|
|
|
Hi there!
I'm writing a server, which shold have an update function. So it should replace it's own executable file with a new version. Has any one an idea how to manage that?
Thank you!
|
|
|
|
|
if MyServer.exe is currently running, it won't be able to overwrite its own exe
What you'll need to do is something like this
in MyServer.exe
Check internet for update
if update available
{
download update package
launch Updater.exe
quit MyServer.exe (saving everything gracefully)
}
---
in Updater.exe
Wait for MyServer.exe to shut down
Depack update package
Launch updated Myserver.exe
quit Updater.exe
---
You might want to set this update process so that it can be scheduled at a quiet time for your server. E.g. if it's main traffic is from 9am - 5pm, then make it try to update at 5am
--
Help me! I'm turning into a grapefruit!
Buzzwords!
|
|
|
|
|
Now I do something about barcode, some barcode uses Fonts, some uses draw lines.
this post is not related to barcode, but it is caused from barcode.
a vertical line can be printed by 2 methods:
1. by font (such as character '|')
2. by drawing (such as LineTo())
as I tested, vertical line is printed much clearer by font than drawing for both laser and inkjet printers, do you know why?
important: do you know how to draw a line imitating vert line of font, which is much clearer than nomal LineTo()?
|
|
|
|
|
hi,
I am looking for way, how to copy text from Windows aplication to
MS-DOS. I just need to get simple text into DOS(window) -such Notepad
There is of course no clipboard support - I thought about simulate key strokes, but is it possible without writing device driver.
Any idea will help
Thanx
viliam
|
|
|
|