Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Windows Suche starten (https://www.delphipraxis.net/157652-windows-suche-starten.html)

Björn Ole 19. Jan 2011 18:49

Windows Suche starten
 
Huhu,


vielleicht suche ich gerade nur nach den falschen Begriffen, denn ich finde absolut nichts.

Ich würde gerne aus meiner Delphi-Anwendung heraus eine Windows Suche starten.
D.h. ich habe einen Button und beim Klicken soll sich ein Explorer Fenster öffnen und nach bestimmten Dateien gesucht werden.

Mit
Delphi-Quellcode:
ShellExecute(0, 'open', PChar(Pfad), nil, nil, SW_SHOWNORMAL);
öffne ich ein Explorer Fenster.
Wie starte ich jetzt die Suche? Oder brauchts einen ganz anderen Ansatz?

Betriebssystem: Windows 7, ab XP wäre optimal.


Gruß,
Björn

NikB 19. Jan 2011 19:12

AW: Windows Suche starten
 
1. Make one reg file (example):
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\MyFind]
@="YourFind"

[HKEY_CLASSES_ROOT\Folder\shell\MyFind\command]
@="C:\\Programs\\YourFind.exe %1\"
2. Exec reg file (double click)
3. Make your program in C:\Programs\YourFind.exe (or other :))
4. Assign command line parameters in your program (%1 is file, click in WinExplorer). Command line parameter in Delphi: ParamCount, ParamStr.

Björn Ole 19. Jan 2011 19:23

AW: Windows Suche starten
 
Sorry, but I'm afraid you didn't understand my problem. ;)

But first, welcome and thanks for trying to help me!

Here's what I'm trying to achieve:
In my application, I have an Edit and a Button.
In the Edit, you find something like created:yesterday size:>100mb *.avi
When I click the Button, an Explorer window should appear (being at a specific directory)
and the text from the Edit should be placed into the search box, so that it automatically starts searching.

Aphton 19. Jan 2011 19:34

AW: Windows Suche starten
 
Lies dir die Dokumentation doch mal genauer durch:
Code:
ShellExecute Function

Performs an operation on a specified file.
Syntax

HINSTANCE ShellExecute(
  __in_opt HWND hwnd,
  __in_opt LPCTSTR lpOperation,
  __in     LPCTSTR lpFile,
  __in_opt LPCTSTR lpParameters,
  __in_opt LPCTSTR lpDirectory,
  __in     INT nShowCmd
);


Parameters

(...)
lpOperation [in, optional]

    Type: LPCTSTR

    A pointer to a null-terminated string, referred to in this case as a verb, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs. The following verbs are commonly used:

    edit

        Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.

    explore

        Explores a folder specified by lpFile.

    find

        Initiates a search beginning in the directory specified by lpDirectory.

    open

        Opens the item specified by the lpFile parameter. The item can be a file or folder.

    print

        Prints the file specified by lpFile. If lpFile is not a document file, the function fails.

    NULL

        In systems prior to Windows 2000, the default verb is used if it is valid and available in the registry. If not, the "open" verb is used.

        In Windows 2000 and later, the default verb is used if available. If not, the "open" verb is used. If neither verb is available, the system uses the first verb listed in the registry.
(...)
Source

Björn Ole 19. Jan 2011 20:02

AW: Windows Suche starten
 
Ah, danke, das hatte ich übersehen.
Aber ich hänge immer noch.

Mein Versuch:
Delphi-Quellcode:
ShellExecute(0, 'find', nil, nil, PChar('C:\'), SW_SHOWNORMAL);
  • Ich kann nur im .exe-Verzeichnis suchen.
    Anscheinend gibt es da eine zeitliche Verzögerung?? :shock: Ich hatte versucht, auf C:\ zu suchen, er listete mir beim Suchbegriff * aber nur alle Dateien aus dem .exe-Verzeichnis auf. Vorm Abschicken dieser Antwort hatte ich es noch ein letztes mal versucht, dann gings auch auf C:\. Keine Änderungen am Quelltext, nicht neu kompiliert.
  • Es gibt anscheinend keine Möglichkeit, den Such-String zu übergeben. Man muss ihn manuell eintippen.
  • Die Suche muss ebenfalls manuell gestartet werden.

Aphton 19. Jan 2011 20:17

AW: Windows Suche starten
 
Zitat:

Zitat von Björn Ole (Beitrag 1075911)
Ah, danke, das hatte ich übersehen.
Aber ich hänge immer noch.
  • Es gibt anscheinend keine Möglichkeit, den Such-String zu übergeben. Man muss ihn manuell eintippen.

Versuch mal, lpParameters als den Such-string zu verwenden!

Björn Ole 19. Jan 2011 20:29

AW: Windows Suche starten
 
Wenn ich lpParameters '*' angebe, zeigt sich keine Änderung.
Wenn ich lpParameters PChar('*') angebe, kommt folgendes:
Zitat:

Access violation at address 7627FB8A in module 'shell32.dll'. Read of address 0000002A

Ich bin immer noch ratlos.

alfold 19. Jan 2011 22:01

AW: Windows Suche starten
 
Gibt es eine Grund warum Du über Shellexecute gehst?
Weil, ich frage mich, wenn ich in delphi proge, dann kann ich doch solche suche selber schreiben und mir in einer Listbox anzeigen lassen!?

Gruss alfold

BUG 19. Jan 2011 23:49

AW: Windows Suche starten
 
Zitat:

Zitat von alfold (Beitrag 1075961)
Weil, ich frage mich, wenn ich in delphi proge, dann kann ich doch solche suche selber schreiben und mir in einer Listbox anzeigen lassen!?

Kannst du?
Ein durch Dienst gepflegten Index ist mit dabei, Sucheingaben wie "created:yesterday size:>100mb *.avi" muss man auch erst einmal auswerten und dann auch noch effizient suchen.
Sicher sind da auch noch tausend Kleinigkeiten, an die man jetzt gar nicht denkt.

Bist man das alleine implementiert hat, sind vermutlich schon ein paar neue Delphiversionen erschienen :mrgreen:

Björn Ole 20. Jan 2011 22:26

AW: Windows Suche starten
 
Exakt.

Ich habe hier nachgelesen, dass der korrekte Aufruf wie folgt lautet:
Code:
ShellExecute(hwnd, "find", "c:\\MyPrograms", NULL, NULL, 0);
Jetzt hab ich Folgendes versucht:
Delphi-Quellcode:
ShellExecute(0, 'find', 'C:\\', nil, nil, 0);

und Eingabe in das Suchfeld: *
Es werden alle Dateien auf C:\ aufgelistet.
Dann ändere ich den Pfad:
Delphi-Quellcode:
ShellExecute(0, 'find', 'D:\\', nil, nil, 0);

Ins Suchfeld wieder: *

Es werden immer noch alle Dateien auf C:\ aufgelistet?? :?

Wo liegt der Fehler? Hab ich was vergessen?


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:27 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz