|
I have a Dialog box (and associated .cpp and .h files) developed in VS6.0 MFC that is called as a modeless dialog from its parent dialog based application. I wish to reuse this in other projects and share with coworkers.
Is there a way to do so, say as a Static Library or DLL perhaps?
I can create the static library using the code, but do not know how to add in the dialog that is related to it.
Are there any examples available I could learn from?
Any help would be greatly appreciated. Thanks.
Ralph_L
|
|
|
|
|
You can use either a static library or a dll, whatever is more appropriate.
If you use a DLL, the DLL needs to be an MFC extension DLL.
Create the appropriate project type and add the cpp and h files, and copy the dialog
resource into the project.
For the DLL, you'll need to change the class declaration:
class AFX_EXT_CLASS CMyDialog : public CDialog
...
For a static library you need to make sure you have a scheme in place so resource IDs
won't clash with the module it's linked with.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Of course, that means that any program that uses the DLL must itself be an MFC app.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I guess I just assumed it was MFC code since the op stated
"developed in VS6.0 MFC".
Stupid me.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I was merely posting a gentle reminder because the OP didn't say that the "other programmers" were writing in C++/MFC.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks. I was merely making sure the other programmers had no choice
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: I was merely making sure the other programmers had no choice
Real men drive manual transmission.
|
|
|
|
|
Hi everybody,
What is the best way in Visual C++(6.0) to make a program wait till a folder is completely copied. I have a program that would constantly watch an Input folder, Job folders are being copied to the Input folder, which I want to move to the InProgress folder for processing, once they are fully copied.
Thank you in advance,
Indu
|
|
|
|
|
icsr wrote: What is the best way in Visual C++(6.0) to make a program wait till a folder is completely copied.
Are you doing this copying via code?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No, the folders are copied out side of the program. The program should be able to identify the folders that are complete, as opposed to the ones that are still in progress. I tried traversing the directory with FindFirstFile and FindNextFile and tried opening the files inside, hoping that if it returns an invalid handle then the directory is still in progress. But this did not work.
Any helpful hints?
Thank you,
Indu
|
|
|
|
|
The only thing I can think of is to try and open the file(s) exclusively. Files that are being copied would not allow such access.
Are you using ReadDirectoryChangesW() for the monitoring?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I also looked at FindFirstChangeNotification, which will trigger an event when directory properties change. Has any body done anything similar, I am running out of options.
Thank you,
Indu
|
|
|
|
|
icsr wrote: I also looked at FindFirstChangeNotification...
This will tell you that some file has changed, but it won't tell you what that file is.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
HANDLE cnh = FindFirstChangeNotification(inDirName, TRUE, <br />
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME|FILE_NOTIFY_CHANGE_SIZE|FILE_NOTIFY_CHANGE_LAST_WRITE);<br />
if(cnh!= INVALID_HANDLE_VALUE)<br />
{<br />
DWORD dwMilSecs = 500;
DWORD wr = WaitForSingleObject(cnh, dwMilSecs);
<br />
if(wr == WAIT_OBJECT_0)<br />
{<br />
<br />
do {<br />
FindNextChangeNotification(cnh);<br />
wr = WaitForSingleObject(cnh, dwMilSecs);<br />
} while(wr == WAIT_OBJECT_0);<br />
}<br />
FindCloseChangeNotification(cnh); <br />
}<br />
<br />
MoveFileEx (inDirName,outDirName, MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED); <br />
<br />
Thank you David for your reply. This is what I have done. Since I only care about whether the directory changed or not, I used WaitForSingleObject. I think my program is not waiting long enough. I am also trying to understand what you have done in FaxWatch. I want to move only the directories that are done copying.
Thank you,
Indu
|
|
|
|
|
icsr wrote: I am also trying to understand what you have done in FaxWatch.
Nothing that would help here. Knowing when an operation starts is easy, but knowing when an operation is done is not. I would hazard a guess that even the OS does not know such a thing. When an application starts a file/folder operation, only it knows when it will be done.
You could try something brute-force like taking a snapshot of the folder when you first detect a change, and then re-checking that folder every few seconds to see if anything differs (e.g., file sizes).
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Would I not get continuous notification if I am watching for FILE_NOTIFY_CHANGE_SIZE and the directory is in progress?
do {<br />
FindNextChangeNotification(cnh);<br />
wr = WaitForSingleObject(cnh, dwMilSecs);<br />
} while(wr == WAIT_OBJECT_0);
I think the OS caching is also making it difficult to monitor.
Thank you,
Indu
|
|
|
|
|
I have written a program which is meant to be run with Administrator privileges: it carries out tasks for the user as an administrator and there is nothing fancy going on here; simply a proof of concept. At some point, the program launches another program, but I would it to launch _without_ admin privileges. I would like it to inherit the user security descriptors but not the admin through the CreateProcess API. I have gone through the Securty/Authorization API and I am able to read and identify SIDs and Permissions LUIDs, etc., but I am at a dead end I would appreciate anyone pointing me in the right direction.
Thanks,
m.bergman
-- For Bruce Schneier, quanta only have one state : afraid.
|
|
|
|
|
Use CreateProcessAsUser() function please.
Hope you can take ideas From this [^] article.
|
|
|
|
|
I have the following (part of openssl source code)
struct EVP_MD
{
int type;
int pkey_type;
int md_size;
unsigned long flags;
int (*init)(EVP_MD_CTX *ctx);
int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count);
int (*final)(EVP_MD_CTX *ctx,unsigned char *md);
int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from);
int (*cleanup)(EVP_MD_CTX *ctx);
int (*sign)(int type, const unsigned char *m, unsigned int m_length,
unsigned char *sigret, unsigned int *siglen, void *key);
int (*verify)(int type, const unsigned char *m, unsigned int m_length,
const unsigned char *sigbuf, unsigned int siglen, void *key);
int required_pkey_type[5];
int block_size;
int ctx_size;
};
My question is in regards to the lines that look like this:
int (*init)(EVP_MD_CTX *ctx);
What the hell is that? It looks like a function pointer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: It looks like a function pointer
Mostly because it is. A pointer to something like.
<br />
int InitFunc(EVP_MD_CTX* ctx)<br />
{<br />
}<br />
the struct member is called init
It looks like an attempt to sort of create a class in 'C' by tying functions to a struct to make them 'member' functions.
Anyway I thought you'd entirely graduated to 'toy' languages like C# and left all this grungy stuff behind?
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I have had to do some pretty wide-ranging stuff. I've converted about 500 lines of PHP code down to 200 lines of C# code, and now my boss wants to see if we can convert part of the PHP source code that deals with openssl signature verification (written in C) to C# (the original message is part of that tasking). In order to convert it, I have to understand what it's doing in the original language. I've already suggested that we at least use C++/CLI, but he really wants it in C#.
I could have avoided this conversion if I could have found a way to verify the signature with the .net crypto stuff. I've never dealt with any kind of crypto stuff before, so I haven't got an earthly clue about where to start or what to look for in that regard (and nobody here or anywhere else seems to know where to point me). I am therefore doomed challenged to convert this code (if possible).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
That explains it. I have full confidence that you'll be able to convert this. C is great for porting because it's simple enough most of the time to be really certain about what it means just from reading it. I've had some great fun porting C to C++ in the past. Even better from what you posted this C was written by a C++ programmer anyway so it's already closer to C# than it might be in really nasty K&R C. Good luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Matthew Faithfull wrote: I have full confidence that you'll be able to convert this.
The problem is that I don't have time to convert it. I'd rather do this with the built in .Net crypto stuff if possible (see my exchange with led_mike).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I sympathise with the time pressure. I'm afarid the Crypto API in C# is about as much out of my league as it gets. I can only wish you luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
John Simmons / outlaw programmer wrote: and nobody here or anywhere else seems to know where to point me
PHP... does that mean a Web Application? So you are trying to convert to ASP.NET?
John Simmons / outlaw programmer wrote: openssl signature verification
Well I would start reading about security, certificates and signatures at a standards level. Once you have a grasp of that the Crypto API documentation will make a lot more sense and finally a .NET interface to it as well.
This[^] is old, but should prove useful. Also I have no current knowledge as to the levels of support in the Frameworks library versions. Also what .NET platform are you on, that likely makes a difference.
|
|
|
|