If you use the "Compare EXE=" setting in UEStudio.ini (or uedit32.ini if you're using UltraEdit) to specify a custom comparison program, you will no longer have the option of comparing selected text.
As a start to working around this problem if instead of adding a "Compare EXE=" setting, you replace ucl.exe with your own program (backup ucl.exe first, of course) that dumps command line arguments and run a normal file comparison, you'll see that "UltraCompare Lite" is invoked with arguments that look like:
Code: Select all
arg[0]: "C:\Program Files (x86)\IDM Computer Solutions\UEStudio\ucl.exe"
arg[1]: "-t"
arg[2]: "C:\temp\launchbc.c"
arg[3]: "C:\temp\echoargs.c"
arg[4]: "-rio"
arg[5]: "-v1253576624"
arg[6]: "-cfd"
arg[7]: "|-1|-1|-1|-13|0|0|0|400|0|0|0|0|0|0|♣|1|Courier New|0|"
I have no idea what most of those arguments are, but it's clear where the files to be compared are. With this information, you can replace ucl.exe with your own program that launches Beyond Compare instead. Here's a simple example that performs no error handling and probably has some bugs:
Code: Select all
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
char bc_prog[] = "C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe";
int main( int argc, char** argv)
{
BOOL result;
int len = strlen(bc_prog) + strlen(argv[2]) + strlen(argv[3]) + 10;
char* cmdline = malloc(len);
PROCESS_INFORMATION ProcessInfo; //This is what we get as an [out] parameter
STARTUPINFO StartupInfo; //This is an [in] parameter
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof StartupInfo ; //Only compulsory field
sprintf(cmdline, "\"%s\" \"%s\" \"%s\"", bc_prog, argv[2], argv[3]);
result = CreateProcess(
bc_prog,
cmdline,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&StartupInfo,
&ProcessInfo
);
if (!result) {
puts("The process could not be started...");
}
else {
//WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
}
return 0;
}
Now, since you're interested in being able to use Beyond Compare to compare selected portions of files open in UEStudio, you'll note that in that case the arguments passed to the compare program by UEStudio are:
Code: Select all
arg[0]: "C:\Program Files (x86)\IDM Computer Solutions\UEStudio\ucl.exe"
arg[1]: "-t"
arg[2]: "C:\Users\mikeb\AppData\Local\Temp\C__temp_echoargs.c0\C__temp_echoargs.c"
arg[3]: "C:\Users\mikeb\AppData\Local\Temp\C__temp_launchbc.c0\C__temp_launchbc.c"
arg[4]: "-title1"
arg[5]: "C:\temp\echoargs.c"
arg[6]: "-title2"
arg[7]: "C:\temp\launchbc.c"
arg[8]: "-rio"
arg[9]: "-v1717702579"
arg[10]: "-cfd"
arg[11]: "|-1|-1|-1|-13|0|0|0|400|0|0|0|0|0|0|♣|1|Courier New|0|"
So temporary files are passed as well as titles to use in the compare program. BC can handle this, but my little wrapper program does not - you'll see the ugly temporary filenames unless you modify the program to look for the "-title" arguments and pass them on.
I leave such modifications and error handling improvements as an exercise for the reader.