/// <summary>Class that implements a custom local URL protocol and reports and URLs received to the delegate method.</summary> /// <param name="name">The name of the custom URL protocol, e.g. "eddi". Typically lower case.</param> /// <param name="urlHandler">Callback delegate to which the incoming URL will be passed. NB since a user can send any URL from the Windows Run dialog, treat the URL as untrusted.</param> /// <param name="logger">Callback delegate on which any errors will be logged.</param> /// <param name="absoluteAppPath">Optional full path to your executable. If null, no registry changes will be made. If supplied, an apprpriate registry key will be created or updated in HKCU.</param> /// <remarks>To test this, set a breakpoint on your urlHandler callback, and send a URL from the Windows Run dialog.</remarks> public CustomURLResponder(string name, UrlHandler urlHandler, Logger logger, string absoluteAppPath = null) { this.urlHandler = urlHandler; this.logger = logger; ddeDelegate = new DdeDelegate(DdeCallback); if (absoluteAppPath != null) { RegisterAppPath(name, absoluteAppPath); } bool success = Setup(name); if (!success) { CleanUp(); } }
// Construct, Start, Call AddTopic(s), Register.... Dispose() in that order. public bool Start(string ddeapplicationname) { ddeDelegate = new DdeDelegate(DdeCallback); uint result = NativeMethods.DdeInitializeW(ref DdeInstance, ddeDelegate, (uint)(0), 0); if (result != 0) { return(false); } ServerNameHandle = NativeMethods.DdeCreateStringHandleW(DdeInstance, ddeapplicationname, (int)CodePages.CP_WINUNICODE); if (ServerNameHandle == IntPtr.Zero) { CleanUp(); return(false); } return(true); }
internal static extern uint DdeInitializeW(ref uint DDEInstance, DdeDelegate pfnCallback, uint afCmd, uint ulRes);