Autor Beitrag
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: So 27.10.02 10:10 
Hallo,
wie kann ich Dialoge der Systemsterung öffnen?

Ich weiß nur das man dies mit einer ShellApi anstellt, ungefähr so müsste es aussehen:


procedure RunControlPanelApplet(AppletFileName: string);
begin
ShellExecute(handle, 'open', PChar('rundll32.exe'),
PChar('shell32.dll,Control_RunDLL '+AppletFileName), nil, SW_SHOWNORMAL);
end;

Aber wo muss ich hier die CPL einbinden?
Es gibt folgende CPLs:

access.cpl
appwiz.cpl
desk.cpl
intl.cpl
joy.cpl
main.cpl
mmsys.cpl
modem.cpl
sysdm.cpl
timedate.cpl
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: So 27.10.02 12:37 
Hi,

ich habe mal folgenden Code verwendet:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TMainForm.Systemoptions(Applet: String);
begin
  ShellExecute(Application.handle,'open',PChar('rundll32.exe'),PChar('shell32.dll,Control_RunDLL '+Applet), nil, sw_shownormal);
end;

//Der Aufruf sieht dann so aus

procedure TForm1.MultimediaClick(Sender: TObject);
begin
  Systemoptions('mmsys.cpl');
end;


Ich hoffe, dass dir das hilft

_________________
Viele Grüße
Jakob
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: So 27.10.02 12:40 
Der Code geht aber nicht!
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: So 27.10.02 12:43 
also bei mir funtzt er einwandfrei. Was hast du denn fürn OS?

_________________
Viele Grüße
Jakob
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: So 27.10.02 12:46 
Ich habe Windows 2000 und benutze Borland Delphi 6.

Delphi sagt beim compilieren: Undefinierter Bezeichner Systemoptions


Zuletzt bearbeitet von Andreas L. am So 27.10.02 12:50, insgesamt 1-mal bearbeitet
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: So 27.10.02 12:49 
benutze ich auch. Hast du die Unit ShellApi eingebunden? Kommt einer Fehlermeldung, beim Compilieren bzw. beim Ausführen. Wenn ja, könntest du diese posten? Oder passiert einfach nichts?

_________________
Viele Grüße
Jakob
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: So 27.10.02 12:52 
Die Unit ShellApi ist im uses Bereich eingebunden.
Die Fehlermeldung ist: Undefinierter Bezeichner Systemoptions
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: So 27.10.02 13:22 
Du musst folgendes noch unter Public Deklaration eintragen :

ausblenden Quelltext
1:
procedure TMainForm.Systemoptions(Applet: String);					
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 27.10.02 13:36 
Wenn DeCodeGuru es nicht als Form-abhängige Prozedur gestalten hätte, gäbe es die Fehlermeldung gar nicht erst, und die Routine ließe sich weit flexibler auch in anderen, evtl. sogar Form-losen Programmen verwenden!

Besser wäre also:
ausblenden Quelltext
1:
procedure Systemoptions(Applet: String);					

Wer Wert auf das Fensterhandle legt (das auch Null sein könnte), ergänzt als weiteren Parameter den Prozedurkopf:
ausblenden Quelltext
1:
procedure Systemoptions(wnd: HWND; Applet: string);					

und übergibt "wnd" als Handle für ShellExecute.

Der Aufruf wäre dann in dem Fall
ausblenden Quelltext
1:
Systemoptions(self.Handle,'mmsys.cpl');					

Auch nicht viel mehr Aufwand, IMHO.
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: So 27.10.02 14:34 
Hi Mathias,

ich habe den Code aus einem meiner alten Programm kopiert und hatte vergessen in zu "modifizieren". :? Aber du hast ja alles so schön ergänzt :wink:

_________________
Viele Grüße
Jakob
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Mo 28.10.02 09:46 
Sorry,
ich werd nicht schlau aus den Beitrag von MathiasSimmack.
Kann mir jemand von euch den ganzen CODE geben!

Bitte, bitte :oops:
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 28.10.02 10:20 
Man nehme die Funktion von DeCodeGuru, reiße sie aus ihrer Form-Verbundenheit und ändere sie wie folgt:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
uses
  ShellAPI;

procedure Systemoptions(wnd: HWND; Applet: String);
begin
  ShellExecute(wnd,'open','rundll32.exe',
    pchar('shell32.dll,Control_RunDLL ' + Applet),
    nil,SW_SHOWNORMAL);
end;


Deine Fehlermeldung
Fehler hat folgendes geschrieben:
Undefinierter Bezeichner Systemoptions

resultierte ganz einfach daher, dass die ursprüngliche Funktion als Teil der Form deklariert war:
ausblenden Quelltext
1:
procedure TMAINFORM.Systemoptions(...);					

Die von mir vorgeschlagene, und von DeCodeGuru für gut befundene "Modifizierung" sorgt dafür, dass sich die Funktion jetzt unabhängig von irgendwelchen Forms in mehreren Programmen verwenden lässt.