|
I want to make rich edit control detect e-mail automatically.
Same as it detect URLs when we set 'EM_AUTOURLDETECT' style through message .
Is there any style we need to set for this purpose?
Thanks..
|
|
|
|
|
The EM_AUTOURLDETECT Message[^] already detects the mailto URL[^]. If you want to add additional functionality then you will have to implement it yourself. You could probably use a combination of EM_FINDTEXT and EM_EXSETSEL to copy all words with the @ symbol and use a pattern matching algorithm to determine if it appears to be an e-mail address. Upon finding said e-mail address replace the text with a valid mailto URL.
Best Wishes,
-David Delaune
|
|
|
|
|
Is it[^] helpful?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
These two APIs are very similar but it is unclear what the differences are and when each should be used (Except that LoadUserProfile is specified for use with CreateProcessAsUser which I am not using. I am simply impersonating for hive accesss).
LoadUserProfile
http://msdn.microsoft.com/en-us/library/bb762281(VS.85).aspx
RegOpenCurrentUser
http://msdn.microsoft.com/en-us/library/ms724894(VS.85).aspx
According to the Services & the Registry article:
http://msdn.microsoft.com/en-us/library/ms685145(VS.85).aspx
we should use RegOpenCurrentUser when impersonating.
But what does/should RegOpenCurrentUser do if the user profile is roaming - should it load it?
As far as I can tell from these docs, both APIs provide a handle to the HKEY_CURRENT_USER for the user the thread is impersonating. Therefore, they both "load" the hive i.e. lock it as a database file and give a handle to it for registry APIs.
It might seem that LoadUserProfile loads the user profile in the same way as the User does when he/she logs on, whereas RegOpenCurrentUser does not - is this correct? What is the fundamental difference (if any) in how these two APIs mount the hive?
What are the implications and differences (if any) between what happens IF
1. A user logs-on or logs-off while each of these impersonated handles is already in use?
2. A user is already logged-on when each matching close function (RegCloseKey and UnloadUserProfile) is called?
|
|
|
|
|
I am designing a Service to run under LocalSystem account on Win2000, XP and Vista. It will need access to users registry hives, sometimes for extended periods of time, both when the users are logged-in, and also, when they are not logged-in (IF the profile is local. If the profile is Roaming and not loaded, I will not attempt to load it.)
If the user is logged-on, I can get the Users access token by various means (E.g. from its Explorer process, or by receiving Logon events from the Service Control Manager) then use ImpersonateLoggedOnUser and RegOpenCurrentUser to access the User's hive. However, what are the implications if the User selects LogOff from the start menu while I am impersonating and have his hive open? Will the logoff be prevented? Will my impersonation be terminated?
If the user is not logged on, I can use RegLoadKey to directly open the hive NTUSER.DAT. (Impossible for a logged-on user). But what are the implications of this if the user decides to log-on (I suppose the hive will be locked and the logon either prevented, or may experience difficulty?)
I will be setting up some test projects to explore these ideas however, regardless of their apparent results, these questions are theoretical in terms of what type of problems might, or would, be caused by the user loggin in/out during these actions by the service.
Caveat: ImpersonateLoggedOnUser can ONLY be used either for a logged-on user (token obtained from process or SCM event) OR for a user for which I have the plaintext password to call WinLogon and obtain a token - TRUE / FALSE ? In other words although I have maximum permissions as LocalSystem and am able to change the user's password or even delete the user's account, if the user is not logged-on, it is totally impossible to create a new token to impersonate the user without having the the password?
|
|
|
|
|
Is there any way to create Media player 10-like toolbar using plain Win32 API?
|
|
|
|
|
If you mean, can an MP10 like toolbar be WRITTEN in C++ using plain Win32 api, i'd say yes. If you mean, can the same control as MP10 uses be "instantiated" in another aplication, no idea, that control IF it is a control at all, is probably implemented in MP itself so that could prove...problematic. But it's just a guess.
p.s: Try using spy++ to check what class that toolbar has and googling for it, maybe it pops up something.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
modified on Tuesday, January 20, 2009 6:24 AM
|
|
|
|
|
I have for example a drive letter, say 'E:\', and I want to programatically check if it's the CDROM. Any way to do that?
Thanks.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
modified on Monday, January 19, 2009 12:16 PM
|
|
|
|
|
|
Thanks, and one more question, does GetDriveType return DRIVE_CDROM for dvd's as well? Because there wasn't any mention of DVDs in the MSDN article.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: does GetDriveType return DRIVE_CDROM for dvd's as well?
Yes, it will return DRIVE_CDROM for all drives which support reading a CD-ROM. One way to determine if the device is actually a DVD-drive is to use DeviceIOControl such as follows:
#include <winioctl.h>
BOOL DeviceSupportsDVDMedia(TCHAR *szDrive)
{
BOOL bRet = FALSE;
if(NULL != szDrive && DRIVE_CDROM == GetDriveType(szDrive))
{
GET_MEDIA_TYPES media[CHAR_MAX];
TCHAR szVol[MAX_PATH] = {0};
DWORD dwBytesRet =0;
int iSize = CHAR_MAX * sizeof(GET_MEDIA_TYPES);
_stprintf(szVol,_T("\\\\.\\%c:"),szDrive[0]);
HANDLE hDevice = CreateFile(szVol,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,0);
if(INVALID_HANDLE_VALUE != hDevice)
{
if(DeviceIoControl(hDevice,IOCTL_STORAGE_GET_MEDIA_TYPES_EX,NULL,0,media,iSize,&dwBytesRet,FALSE))
{
bRet = FILE_DEVICE_DVD == media->DeviceType;
}
}
}
return bRet;
}
Best Wishes,
-David Delaune
[Updated January, 15, 2010]
I was contacted by a member regarding this code sample. I noticed the code sample was very poorly written (sorry bout that). I have updated it.
modified on Saturday, January 15, 2011 4:33 AM
|
|
|
|
|
DriveComboBox[^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
?
modified on Tuesday, January 20, 2009 4:02 AM
|
|
|
|
|
You can't instantiate an abstract class. Full stop. No argument. All you can do is derive a class from the abstract class that implements the abstract method(s) and instantiate one of those. The derived class pointer is convertible to a pointer to the abstract base class, so can be used in its place - see the code below.
class A{
public :
A(){};
virtual ~A(){};
virtual void do()=0;
};
class B : public A
{
public:
B() {}
virtual ~B() {}
virtual void do() { std::cout << "In B::do\n"; }
}
void Blah(A* pA) { pA->do(); }
void main()
{
B* pB=new B();
Blah(pB);
}
I've also made the destructor virtual - it's always safest to make destructors virtual if a class has any virtual method, in case the destructor gets called from a base class pointer/reference.
|
|
|
|
|
Stuart Dootson wrote: Full stop. No argument
I'm not satisfied with this answer. I need to know why. So if it is theoretically impossible to instantiate an abstract class, my aim is to understand how the compiler is able to do that.
OK I know that "instantiating an abstract class" is moral issue ( ) ;
But my aim is not to break that moral barrier in my programming life, rather understand how does the compiler ensure that that barrier is not broken.
Just posting the question before I'll go and see the source code of a C++ compiler, in the aim that may be there is an answer.
|
|
|
|
|
hINTModuleState wrote: OK I know that "instantiating an abstract class" is moral issue
Is not a moral issue, it is a explicitely forbidden by the language.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I used the expression "moral issue" in order to qualify an act that is against the rules of design.
instantiating an abstract class is explicitly forbidden by the langage, because the design rule says
that we can only instantiate derives of the abstract class. This is the explicit statement, but what about the compiler implementation ?
|
|
|
|
|
If the target is just fooling the compiler, then your (im my opinion, ta least) question is pointless.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hINTModuleState wrote: Just posting the question before I'll go and see the source code of a C++ compiler, in the aim that may be there is an answer
Go on then...I think you may find the source of a C++ compiler less than straight forward.
hINTModuleState wrote: I need to know why
It's because you have undefined method pointers in the classes vtable (the methods you declared abstract have no definition, so cannot be referenced). Thus, the class is (in terms of instantiation) not fully defined, so creating an object of that type is erroneous.
|
|
|
|
|
Stuart Dootson wrote: It's because you have undefined method pointers in the classes vtable
I know that I have a vtable with empty case for the undefined virtual function..but do we know how and when the compiler checks that vtable ?
|
|
|
|
|
hINTModuleState wrote: do we know how and when the compiler checks that vtable ?
yes.
it does not.
it generates the data that will go there, if any.
|
|
|
|
|
The compiler doesn't check the vtable - it creates it. That's why the compiler won't let you instantiate an abstract class - by doing that, it can guarantee you don't try to call an undefined method.
|
|
|
|
|
Here's[^] a nice article explaining abstract classes and how a pure virtual method can be called in obscure circumstances.
|
|
|
|
|
thank you for that valuable link.
|
|
|
|
|
hINTModuleState wrote: I'll go and see the source code of a C++ compiler
great idea. When you're through, please provide an abstract, maybe an article would be nice. So we all can learn new things.
|
|
|
|