I'm looking for some information how to replace the default email program within Windows. So far I've been able to find limited information about changing the registry keys to point to a custom coded DLL. Microsoft mentions that there is a MAPI stub which is saved as Windows\System32\MAPI32.dll and there are functions that need to be implemented but not much detail on how it must be done.
I'll be writing the main program in C# but get the feeling I'll need to write the custom MAPI DLL in unmanaged C/C++
Any links or insight would be helpful.
Thanks.
Two things I can think of
modifying default email program is not related to DLL. See KB 299853. The sample is in VB but you can easily change it to C#.
associate the mailto: protocol to your program, which is already discussed here
Thanks Peon for the info.
Part of my research brought me information about Mozilla's Thunderbird.
Thunderbird may not fully implement Simple MAPI as many people have mentioned. However it gives a great outline of the DLL stub that needs to be overridden.
Anyone looking into creating a default email client, or at least acts like a default email client should look at the Thunderbird source code ( available off Mozilla's website ).
Also, install Thunderbird. It creates all of the proper registry changes that you'll also need to make.
https://stackoverflow.com/questions/38074930/windows-application-crash-issue-with-dllmain-c
use registry to change default email client. And code from the link will help you to run your code.
Code is in c++.
Related
So I've recently been looking into the Control Panel, to try to see how I might be able to create a custom applet for it, like sometimes you get a custom one when you use a printer, and I just can't seem to figure out how to make one. I've tried opening one of them in a code editing software, and assume that they are compiled as all I get is a bunch of random characters, but I'm not quite sure whether it is or not. I've looked for anything related to it, but the closest thing to an answer I have is something about trying to make the applet show up, but it doesn't say how it's made, so its not really useful.
Thanks in advance.
There are two types of control panel applets:
.Exe files. These are normal applications and can be written in any language.
.Cpl files. These are actually normal .DLL files and can be written in anything that can produce a PE DLL with a named exported function (C/C++, Delphi or if you must, C#).
Support for .Exe applets started in Vista and is now the preferred method according to Microsoft.
I've created an application in the past, in Lazarus Pascal, which execute "dd" to write an image to a drive. For this, obviously, elevated rights are needed.
In the initial version I have used AuthorizationExecuteWithPrivileges() (link), even though not exactly intended for this purpose, it did work very well and very consistently.
This function however has been depreciated since OSX 10.7, as it can be a security issue, and command line statements that redirect do not work properly either (redirecting output from zip as input for dd).
In the next version I've used a method described in the Lazarus Pascal Wiki (Executing External Programs), which basically starts a TProcess which my program communicates with. Using sudo -S dd ..., the users password is asked and entered to make sure he/she has the proper access rights.
Obviously a little bit of a dirty hack method, and it shows, certain users experience issues with this.
After doing a lot of reading, it seems Apple prefers this to be done with a helper tool called SMJobBless(). I'm unfortunately not very experienced when it comes to Objective-C, the presented code seems very minimal at best and not very well documented either.
I was wondering if anyone has experience or could assist in "porting" this method to Lazarus Pascal ... I'm all in favor of doing it right.
Alternative methods are most welcome as well of course!
Any help would be greatly appreciated.
I'm unfortunately not very experienced when it comes to Objective-C
Don't let this put you off from using the example provided by Apple. If you look closely at the code in SMJobBlessAppController.m, you'll see that other than one line of Objective-C code, the rest is simply C.
The Objective-C line registers the helper application: -
if (![self blessHelperWithLabel:#"com.apple.bsd.SMJobBlessHelper" error:&error])
You'd use your own URI, instead of com.apple.bsd.SMJobBlessHelper.
All the other relevant lines are plain C functions. Breaking this down, you're left with: -
// Obtain rights
AuthorizationCopyRights(self->_authRef, &authRights, kAuthorizationEmptyEnvironment, flags, NULL)
//Start the helper
SMJobBless(kSMDomainSystemLaunchd, (CFStringRef)label, self->_authRef, &cfError);
I've left out checking for error codes, but I hope this has shown just how little code you need to work with and very little Objective-C knowledge is required.
Since it took me a lot of work and figured it would be helpful to others, here my final working solution.
https://www.tweaking4all.com/software-development/lazarus-development/macos-smjobbless-elevated-privileges-lazarus-pascal/
You'll find there an example project and tons of info.
The steps to reproduce this are quite extensive, so here a short recap:
I've been using CFMessages to send messages to the Helper Tool since I had no bindings for NSXPCConnection.
The Helper Tool has to be based on the Lazarus Pascal template "program" or "simple program", and cannot based on any of the TApplication classes, and cannot create any treads.
For the Helper Tool, one needs to create a info.plist and a launchd.plist, which both must be embedded into the binary.
The Main (test) Application can be any Lazarus Pascal application, but needs a proper Info.plist as well, indicating that the Helper Tool is allowed to start with elevated privileges.
The Helper Tool and the application app bundle both need to be signed with a valid Apple Developer ID.
Some missing bindings need to be put in place:
const kSMRightBlessPrivilegedHelper = 'com.apple.ServiceManagement.blesshelper';
function SMJobBless(domain:CFStringRef; executableLabel:CFStringRef; auth:AuthorizationRef; outError:CFErrorRef): boolean; external name '_SMJobBless'; mwpascal;
var kSMDomainSystemLaunchd: CFStringRef; external name '_kSMDomainSystemLaunchd';
And the proper frameworks needs to be included:
{$linkframework ServiceManagement}
{$linkframework Security}
{$linkframework Foundation}
{$linkframework CoreFoundation}
{$calling mwpascal}
And let's not forget to set callback function to handle incoming messages.
I hope this is useful to someone ... :-)
Hello,
Is there VBScript code for Restart Manager (see link here) code to make Microsoft Word close and re-open?
I used Microsoft Word as an example. I just wanted to send the message to RestartManager to close specific application.
I've to read all the RestarManager documentation and get into this to catch what you are trying to do.
And you are right. This is a elegant solution to a lot of problems.
BUT, you have two problems.
First, from the Guidelines for applications in Restart Manager, the behaviour observed in word has to be coded in application. Applications need to be aware of the Restart Manager and know how to act. But well, maybe your applications handle it, but ...
Second is Microsoft does not provide a COM interface to the API. From the documentation: The Restart Manager DLL exports a public C interface that can be loaded by standard or custom installer.
So, a wrapper needs to be written.
Anyway, for a "scripting" workaround, InnoSetup pascal scripting lets you make use of the Restart Manager API.
I have seen many links that talk about 32feet.NET library. I need to know how to use this in C#. Pretty much everything uses Visual Basic but I am not too familiar with that language. I do prefer to do it C#. As additional information, the application will be sending data similar to a serial interface. This means that it will be sending bytes to a device that will respond with bytes as well. I am trying to use the built-in bluetooth but I cannot find the port associated with that nor am I able to detect it using other examples online, I have tried the Power Shell example as well.
The thinking was when I wrote the documentation was that there were a lot of VB users using the library, and that all C# users would be able to read the VB code, even if they weren't able to write VB themselves. See http://32feet.codeplex.com/wikipage?title=Visual%20Basic%20Samples for some help.
Have a go at looking at the examples and see if you can pick out the real code in there -- I myself find it hard to ignore the If, Then, End etc words but can manage it. I've just updated the main pages to include C# versions of the samples, when I have some more free time I'll do some more. :-)
I am trying to find some code which shows how one might open an Outlook NK2 names cache file. I did some searching and I have seen several people say that it's not possible, but then I find links to some freeware that can do just this so I know its possible. I would use the freeware applications, but would rather do it in my own code, and it easier to get an approval from management if I use my own code within my organization rather then a freeware/shareware application. I'm trying to write the code in VB, but I would like to find a example in any language if it helps.
Redemption has some Nk2 examples, although you may have to pay for a commercial license.
There is also a project on Google Code that has a lot of good stuff in it to get you started.