|
How to lock a folder using MFC application
|
|
|
|
|
You cannot.
Nibu thomas
Software Developer
|
|
|
|
|
There are two simple method in xp sp2
method 1:
1. compresss the folder
2. set password
method 2:
1. right click the folder
2. click properties
3. click secutity tab
4. set permission
OR
there are lot of software to lock the folder. but it is not secure
JAYARAJ
|
|
|
|
|
Through MFC ?
Nibu thomas
Software Developer
|
|
|
|
|
No NOT in MFC
this future is in windows xp sp2
JAYARAJ
|
|
|
|
|
Hi,
I have a DLL which has a class containing static members. In the
implementation file of the class I have done proper initialization of
the static data. These static data are public thus I want to modify
these public static data from another application using this DLL.
Somehow the static initialization is not happening if it is done in the
implementation file and while accessing the storage for static data my
VC7 compiler complains that I am trying to write to an illegal memory.
But if I do the static initialization in the header file itself then I
get no run time error. As far as I know static data initialization
should not be done in header file. So really my question is why is this
happening in the first place and what I need to do to fix it?
DLL CODE:
///////////////////////////////Header
file//////////////////////////////////////////
typedef void (*fptr)(void);
class DllMethods
{
public:
__declspec(dllexport) static int data;
__declspec(dllexport) static fptr function;
};
/////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////Implementation
file//////////////////////////////
#include "DllMethods.h"
//IF THIS INITIALIZATION IS DONE IN THE HEADER FILE FOR THE DLL
//THEN I GET NO ERROR WHEN DEBUGGING WITH VC7 COMPILER
fptr DllMethods::function = 0;
int DllMethods::data = 46;
///////////////////////////////////////////////////////////////////////////////////////
APPLICATION CODE:
#include "DllMethods.h"
#include
using namespace std;
static void anotherFunction(void)
{
cout << "Inside anotherFunction" << endl;
}
int main(int argc, char ** argv)
{
//I GET RUNTIME ERROR WHEN THE FOLLOWING LINE
//EXECUTES AND WHEN THE STATIC INITIALIZATION IS
//DONE IN THE IMPLEMENTATION FILE
//BUT IF THE INITIALIZATION IS DONE IN THE HEADER ITSELF
//THEN I GET NO ERROR
//ASSIGN THE FUNCTION PTR OF THE DLL TO THE FUNCTION
//IN THE APPLICAITON
DllMethods::function = anotherFunction;
DllMethods::function();
return 0;
}
PS: I had done this posting some days back as well but got no replies, thus reposting it. IF the question is not clear, then please drop a reply so that I can reform my question.
Thanks in advance for any suggestions /comments,
Divick
|
|
|
|
|
Divick wrote: class DllMethods
{
public:
__declspec(dllexport) static int data;
__declspec(dllexport) static fptr function;
};
class __declspec(dllexport) DllMethods
{
public:
static int data;
static fptr function;
};
This is to be done in the header file when compiling the DLL but when you use it replace the following __declspec(dllexport) with __declspec(dllimport) . It should look like this
class __declspec(dllimport) DllMethods
{
public:
static int data;
static fptr function;
};
A better option would be this
#ifdef INDLL
#define LIBSPEC __declspec(dllexport)
#else
#define LIBSPEC __declspec(dllimport)
#endif Add the above to your header file. In the DLL project define the macro INDLL hence LIBSPEC will expand to __declspec(dllexport) and outside the DLL don't define INDLL hence it will expand to __declspec(dllimport) .
class LIBSPEC DllMethods
{
public:
static int data;
static fptr function;
};
Nibu thomas
Software Developer
|
|
|
|
|
Hi Nibu,
that really works, but what really is the purpose of dllimport? I normally use dlls by exporting their functions and simply linking with their .lib files and including the header for the function declarations. And I do not do dllimport.
Thanks a lot for the reply,
Divick
|
|
|
|
|
If you don't do dllimport it won't work. Wondering how it works for you.
Nibu thomas
Software Developer
|
|
|
|
|
hello friends Thank you very much for spending your valuable time for finding solution to my problem. I tried the steps suggested by both of you & both are working . I was stucked into that problem from last 1-2 hrs.
Thank once again.
Shoaib.
patel.shoaib@gmail.com
|
|
|
|
|
Hi, All
i want to draw lines and text on a picturebox.
how can i do it, also i want to update the
lines on it's paint event, but problem is that
picturebox paint event is not present in class
wizrad,so how can i generate paint event and draw
lines/text in it?
Regards
Masood
|
|
|
|
|
Just add a WM_PAINT handler.
Nibu thomas
Software Developer
|
|
|
|
|
Thanks
but it will refresh the form and pictrebox, how can i
cause only the picturebox to be refreshed. Any idea
how to obtain drawing handle for picturebox, little code
will be helpful for me.
Regards
Masood
|
|
|
|
|
If you want to do stuff like that, subclass the picturebox and handle WM_PAINT . Don't write picture box painting code inside dialog WM_PAINT handler.
Nibu thomas
Software Developer
|
|
|
|
|
Add WM_PAINT and this function OnPaint
You can use handle dc(CPaint dc(this)
dc.line..
dc.textout
|
|
|
|
|
Thanks for providing code
would not it draw the line/text on form,
i want to draw on picturebox, is there any way to
generate paint event for picturebox as provided
in vb, c# etc.
Regards
Masood
|
|
|
|
|
Hi Engineer Masood,
I m not sure because i dont test this suggestion but
I think you can derived from one class that you need and then insert wm_paint in the derived class
|
|
|
|
|
Hi ,
What is the best way for working with hardware in VC++?
Please help me,
Thanks.
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
i doubt that you will get any answers with this question, please post what are you trying to do, which hardware do you want to work with?
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Hi dSolariuM,
With which hardware (mouse,keyboard...)
and what do you need?
|
|
|
|
|
Hi!
I have made menu item dynamically, by CWnd::InsertMenu
I don't know how to add command handlers to new items, which
I create dynamically.
Can you help me?
Thanks.
|
|
|
|
|
Just add WM_COMMAND handlers using the id of the menu you created. Keep track of the ids.
Nibu thomas
Software Developer
|
|
|
|
|
The problem is that I don't know the ID of my command at compile-time.
I'm reading menu data from database and building menu dynamically at run-time.
So event handlers must be set at run-time also.
|
|
|
|
|
You can override OnCommand and handle the menu events. For more info look up OnCommand in MSDN .
Nibu thomas
Software Developer
|
|
|
|
|
you can use ON_COMMAND_RANGE(id, idLast, memberFxn) to handle a rande of id's.
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|