![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Командная строка [D7, WinXP]
Ralf © (2004-11-28 14:53:00)Как можно переслать командную строку из второго экземпляра программы в первый.
OSokin (2004-11-30 19:47:00) [1]Ж-жуть. Но у меня вообще вариант тоже жуткий: создать DC и передавать по нему данные цветом.
OSokin (2004-11-30 19:46:00) [2]Ж-жуть. Но у меня вообще вариант тоже жуткий: создать DC и передавать по нему данные цветом.
Leonid Troyanovsky (2004-11-29 15:58:00) [3]
> Ralf © (28.11.04 14:53)
> Как можно переслать командную строку из второго экземпляра
> программы в первый.
Вот пример by Michel Winter:
On double click, the shell searches the registry whether the application
registered for that file type is able to receive DDE commands. If it
isn't, the shell starts one application per file. If it is, the
application is started if it doesn't run already, and after a while it
receives the file names.
Hopefully helpful example follows.
Our application should become informed on double clicks on files with
the extension '.myfile'. Our application's name is DdemlDemo.exe, and it
resides in c:\projects\dummy\DdemlDemo\.
First of all, we link the file extension to our application:
--------
REGEDIT4
[HKEY_CLASSES_ROOT\.myfile]
@="MyFile"
[HKEY_CLASSES_ROOT\MyFile]
@="My fine file"
[HKEY_CLASSES_ROOT\MyFile\Shell]
@=""
[HKEY_CLASSES_ROOT\MyFile\Shell\Open]
@="&Open"
[HKEY_CLASSES_ROOT\MyFile\Shell\Open\command]
@="C:\\Projects\\Dummy\\DdemlDemo\\DdemlDemo.exe"
[HKEY_CLASSES_ROOT\MyFile\Shell\Open\ddeexec]
@="[open(\"%1\")]"
[HKEY_CLASSES_ROOT\MyFile\Shell\Open\ddeexec\Application]
@="DdemlDemo"
--------
The DDE commands coming from the shell will look like
[open("C:\00\test1.myfile")]
and we simply show them in a memo box. Parsing and reacting is left as
an exercise for the reader.
I want to point out that it's possibly a good idea to do that DDE stuff
in an extra thread, namely if the application does some longer -time
calculations at startup or sometimes while executing. In that case, the
shell will assume (properly) that the appliaction doesn't react any
more, and it will start a new one.
Here comes the code, without error handling.
--------
uses
Ddeml;
const
OurServiceName = 'DdemlDemo';
var
DdeInst: Integer;
function hsz2Str(Ahsz: HSZ): String;
var
L: Integer;
begin
Result := '';
if Ahsz = 0 then exit;
L := DdeQueryString(DdeInst, Ahsz, nil, 0, CP_WINANSI);
if L
Игорь Шевченко (2004-11-28 16:19:00) [4]
> Как можно переслать командную строку из второго экземпляра
> программы в первый.
WM_COPYDATA ?
XProger (2004-11-28 15:40:00) [5]ShellExecute
ParamCount
ParamStr(1)
прочитай их описание