|
When you click the class in class sheet, you'll see a property sheet. It is like the class wizard for adding message handlers and overwriting virtual functions.
If you use Dialog DDV/DDX, the adding variable members is for it.
|
|
|
|
|
I am about to have a go at writing my own service application. But before I start, I have a few questions I have unable to find reasonable answers to.
An article on CP states that a service is loaded at boot time before any users log on to the system. The service I intend to create is dependant on some system variables to be set which means the user is required to be logged on. This leads me to my question. Since the service requires the user to be logged on, I also want to be able to configure it for each user, which would probably require reading some HKCU registry keys. But how should I handle the case where more than one user is logged on, would the service be run as a seperate instance?
When installing the service, is it possible to do so without admin privlages?
|
|
|
|
|
The service runs in the context of a user so HKCU registry keys are of little/no help.
Running as a separate instance I don't think is possible.
Is there a way you can communicate with the service when a user logs on and send it the variables
it needs?
Otherwise, it sounds more like an app that runs in the background from the users Startup folder situation.
WalderMort wrote: When installing the service, is it possible to do so without admin privlages?
No.
Mark
|
|
|
|
|
Hi,
I wish to create .msg file by using Api calls without using MAPI...I have
all the details of mail item which can be get from .eml file...
Please suggest me where i can get the info for creating .msg files
without using MAPI and any third party tools should not be used...
Regards,
nag.
|
|
|
|
|
Hi,
I'm currently writing a small server application for data transfer. Two commands are for direct file transfer (relative path, e.g. test/data.dat) and I want to limit the filenames to be in the directory and subdirectories of the server application.
Let's say the server lies in c:\server\server.exe, now I want to be able to e.g. put a file into c:\server\new folder\test.dat, but not outside the server directoy, e.g. c:\test.dat (e.g. with a ../test.dat or new folder/../../test.dat).
Is there a good way to parse bad filenames/path?
Greetings
|
|
|
|
|
It is not clear what you need to do. I don't know what a "bad filenames/path" is. I am not sure if you must recognize incorrect syntax of if you need to allow access to something and not allow access to other things.
File access is typically controlled using the built-in features of the NTFS.
|
|
|
|
|
Per your subject, you need to read up on Access Control List (ACL). There's a whole API for it.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
One way, if youv'e got absolute paths, just compare them as strings/char arrays.
You can get absolute paths by using _fullpath() or _wfullpath.
Then you can do the compare, something like this (beware! Old C syntax here):
NOTE! I didn't find the time to set current directory to c:\server before testing the code, so I made a full path name for goodRelPath. Else, I could have used a relative path for goodRelPath.
char * projectDir = "c:\\server\\";
char * goodRelPath = "c:\\server\\new folder\\test.dat";
char * badRelPath = "c:\\test.dat";
char tempFullPath[MAX_PATH];
_fullpath(tempFullPath, badRelPath, MAX_PATH );
if(strstr(tempFullPath, projectDir) == projectDir)
{
}
else {
}
_fullpath(tempFullPath, goodRelPath, MAX_PATH );
if(strstr(tempFullPath, projectDir) == projectDir)
{
}
else {
}
-- modified at 0:43 Tuesday 12th December, 2006
Better code...
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Thank you for your help and the example. Great
|
|
|
|
|
I'm glad to be able to help you.
I have a faint memory of using this technique in a program system in the past (15 years ago, or even longer). It was in the DOS days, and there was a DOS call to convert a relative path to a canonical path name.
Well, the principle worked then, and should do so today.
Good luck.
Kakan
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Hi,
How many threads are there in a simple MFC dialog based Application.
Thanks in advance.
-- modified at 4:07 Tuesday 12th December, 2006
|
|
|
|
|
|
Can you spend a little more time thinking about what you need to ask?
|
|
|
|
|
vc++_fragrance wrote: Can anybody say...
I could but I doubt you'd be able to hear me!
There is at least one thread for any application, MFC or otherwise.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello folks,
I want to search all of files under some directory. For example, dir\file1.txt,
dir\file2.txt,
dir\file3.txt,
...
When using ::FindFirstFile and FindNextFile, I can get all files, and then I can process them. But because the processing may last long, I want to use multithread, but There are strage errors. Can ::FindFirstFile/FindNextFile be multithread? or Are they thread safe?
Thanks in advance.
Haifeng
|
|
|
|
|
rgbalpha wrote: There are strage errors
what errors?
nave
|
|
|
|
|
Yes they can, but don't make changes to the directory structure because they may fail. In your case I would use a thread to get the subdirectories only, then launch another thread to process the files in the directory ( you may want to take a look at thread pooling to do this ). Be very careful about where you are writing your results. Your problem sounds to me like two threads trying to write to the same location.
|
|
|
|
|
|
Each time when the program find a file, it send it to the file_handler() to process. The file_handler() is a function in where I create another thread to process the file. It is like this:
void CMyDoc1::file_handler(LPCTSRT pFileName)<br />
{<br />
m_fileName = pFileName;<br />
AfxBeginThread(ThreadProc, this);<br />
}<br />
UINT ThreadProc(PVOID pParam)<br />
{<br />
CMyDoc1* pDoc = pParam;<br />
pDoc ->FileProcessor();<br />
return 0;<br />
}
The error occurs in FileProcessor(), when free the memory.
-- modified at 6:47 Monday 11th December, 2006
|
|
|
|
|
rgbalpha wrote: ...when free the memory.
Where?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In FielProcessor()
{
new pFile = File();
delete pFile; // Error when there are nearly 25 threads. The first serval threads are OK.
}
|
|
|
|
|
Multithreading can easily be a problem. It requires a lot of thought. It is highly likely that the problem has nothing to do with FindFirstFile/FindNextFile and therefore it is unlikely you have provided enough information to allow anyone to help.
|
|
|
|
|
It is not safe to have mutiple threads messing with the same find handle as the same time. It should be safe to first construct the full path to the file and pass it to a thread like you later examples demonstrates, but you have to make sure that the memory pointed to by the filename parameter is valid for as long as the thread needs it. This is the kind of situation where "hand-off" memory can be used, either by allocating a TCHAR buffer via new[] and passing it to the thread which will later call delete[] on it, or passing a string object.
For these kinds of situations, you may want to use a pool of threads with something like an I/O Completion Port and throw processing requests at it. That way, you do not create too many threads bogging the system down (you do not want to create 1500 threads if 1500 files need to be processed), and you can adjust the number of threads in the pool depending on the resources available on the target system and/or the performance needs of the application.
You can also look into seeing if the QueueUserWorkItem(...) function is available on the target system and use it to manage the thread pool and the work to be done.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi,
Thank you for the solution. I'll have a try this method.
Best Regards,
Haifeng
|
|
|
|
|
Please help,
How can I fix this error:
Error 1 fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\afxver_.h 77
Many Thanx
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|