dys7opia
asked on
write to registry
Okay, what's the code to write a string to the registry.
The string I want is:
HKEY_CLASSES_ROOT\txtfile\ shell\open \command
I'm doing this so I can make my program the default notepad. I really appreciate your help, thanks a lot! :)
The string I want is:
HKEY_CLASSES_ROOT\txtfile\
I'm doing this so I can make my program the default notepad. I really appreciate your help, thanks a lot! :)
ASKER
I put in:
-------------------------- ---------- ---------
procedure SaveSettings(Sender: TObject);
var
hndKey: HKey;
ValBuf: PChar;
cb: Longint;
begin
RegCreateKey('HKEY_CLASSES _ROOT\txtf ile\shell\ open\comma nd',hndKey );
RegSetValue(hndKey,'Test', 'Test');
RegCloseKey(hndKey);
end;
-------------------------- ---------- ---------
and it keeps giving me this error:
"Incompatible Types: 'HKEY' and 'STRING'"
Do you know what this means and how I can fix it? Sorry, I'm still in the learning process of Delphi, only been doing it for about a month or so, thanks :)
--------------------------
procedure SaveSettings(Sender: TObject);
var
hndKey: HKey;
ValBuf: PChar;
cb: Longint;
begin
RegCreateKey('HKEY_CLASSES
RegSetValue(hndKey,'Test',
RegCloseKey(hndKey);
end;
--------------------------
and it keeps giving me this error:
"Incompatible Types: 'HKEY' and 'STRING'"
Do you know what this means and how I can fix it? Sorry, I'm still in the learning process of Delphi, only been doing it for about a month or so, thanks :)
API registry methods take time to learn. You could use the Delphi registry methods, here's somethin from the Delphi Help
procedure TForm1.Button1Click(Sender : TObject);
var
Reg: TRegIniFile;
begin
if Length(NameofKey.Text) or Length(ValueforKey.Text) <=0 then
Showmessage('Either the key name or value is missing.')
else
begin
Reg:=TRegIniFile.Create;
try
Reg.RootKey:=HKey_Local_Ma chine; // Section to look for within the registry
if not Reg.OpenKey(NameofKey.Text ,False) then
if MessageDlg('The specified key does not exist, create it?'
,Mtinformation,[mbYes,mbNo ],0)=mryes then
begin
Reg.CreateKey(NameofKey.Te xt);
if not Reg.OpenKey(NameofKey.Text ,False) then
ShowMessage('Error in Opening Created Key')
else
Reg.WriteString('Value1',V alueForKey .Text);
end
else
Reg.WriteString('Value1',V alueForKey .Text);
finally
Reg.Free;
end;
end;
end;
procedure TForm1.Button1Click(Sender
var
Reg: TRegIniFile;
begin
if Length(NameofKey.Text) or Length(ValueforKey.Text) <=0 then
Showmessage('Either the key name or value is missing.')
else
begin
Reg:=TRegIniFile.Create;
try
Reg.RootKey:=HKey_Local_Ma
if not Reg.OpenKey(NameofKey.Text
if MessageDlg('The specified key does not exist, create it?'
,Mtinformation,[mbYes,mbNo
begin
Reg.CreateKey(NameofKey.Te
if not Reg.OpenKey(NameofKey.Text
ShowMessage('Error in Opening Created Key')
else
Reg.WriteString('Value1',V
end
else
Reg.WriteString('Value1',V
finally
Reg.Free;
end;
end;
end;
HKEY_CLASSES_ROOT\txtfile\ shell\open \command
Reg:=TRegIniFile.Create;
try
Reg.RootKey:=HKEY_CLASSES_ ROOT;
Reg.OpenKey('txtfile\shell \open\comm and',False );
Reg.WriteString('', 'C:\WINDOWS\NOTEPAD.EXE %1');
finally
Reg.Free;
end;
Reg:=TRegIniFile.Create;
try
Reg.RootKey:=HKEY_CLASSES_
Reg.OpenKey('txtfile\shell
Reg.WriteString('', 'C:\WINDOWS\NOTEPAD.EXE %1');
finally
Reg.Free;
end;
ASKER
All of the code you guys have shown me seem to be very similiar, so it must work. But I have to be doing something wrong...but I dont know what! With each of the code I tired it keeps saying:
"Not Enough Actual Parameters"
I dont know how to resolve this....sorry for being a other. :\
"Not Enough Actual Parameters"
I dont know how to resolve this....sorry for being a other. :\
ASKER
a bother****
i hate typos, heh :)
i hate typos, heh :)
can you show your code?
Delphi Help (add Registry in you 'uses' clause):
function GetRegistryValue(KeyName: string): string;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create(KEY_READ) ;
try
Registry.RootKey = HKEY_LOCAL_MACHINE;
// False because we do not want to create it if it doesn't exist
Registry.OpenKey(KeyName, False);
Result := Registry.ReadString('VALUE 1');
finally
Registry.Free;
end;
end;
function GetRegistryValue(KeyName: string): string;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create(KEY_READ)
try
Registry.RootKey = HKEY_LOCAL_MACHINE;
// False because we do not want to create it if it doesn't exist
Registry.OpenKey(KeyName, False);
Result := Registry.ReadString('VALUE
finally
Registry.Free;
end;
end;
your code could be better, here is some code that works for me to read a string value from the registry. . . When you deal with the registry do not assume that a value will be there or that a "Name" of a Data value will contain the type of value (string, integer, boolean) that you expect, TEST IT FIRST!
function TForm1.GetRegistryValue(Ke yName, DataName: string): string;
var
Reg1: TRegistry;
Str1: String;
RDInfo1: TRegDataInfo;
begin
Result := '';
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_LOCAL_MACHINE;
{the registry can be changed by the user and any program,
so you must test all values to see if they exist and to see
if they have the kind of data you want to read}
if not Reg1.OpenKey(KeyName, False) then Exit;
if not Reg1.GetDataInfo(DataName, RDInfo1) then Exit;
if RDInfo1.RegData = rdString then
Result := Reg1.ReadString(DataName);
finally
Reg1.Free;
end;
end;
procedure TForm1.but_WriteRegClick(S ender: TObject);
begin
Label6.Caption := GetRegistryValue('\Softwar e\Microsof t\Internet Explorer\Main', 'Window Title');
end;
function TForm1.GetRegistryValue(Ke
var
Reg1: TRegistry;
Str1: String;
RDInfo1: TRegDataInfo;
begin
Result := '';
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_LOCAL_MACHINE;
{the registry can be changed by the user and any program,
so you must test all values to see if they exist and to see
if they have the kind of data you want to read}
if not Reg1.OpenKey(KeyName, False) then Exit;
if not Reg1.GetDataInfo(DataName,
if RDInfo1.RegData = rdString then
Result := Reg1.ReadString(DataName);
finally
Reg1.Free;
end;
end;
procedure TForm1.but_WriteRegClick(S
begin
Label6.Caption := GetRegistryValue('\Softwar
end;
ASKER
Okay...I just cant seem to get it to work. I dont see why though :(
Okay, I'm just gonna post the code to my program. I dont care if you steal it...but I prefer you not to, but who's stopping ya? Open source forever! :P
//------------------------ ---------- ---------- ----------
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdActns, ActnList, Menus, ExtActns, ComCtrls, ToolWin, ImgList,
StdCtrls, StrUtils, ExtCtrls, clipbrd, OleCtrls, VCSpell3;
type
TMainForm = class(TForm)
MainMenu: TMainMenu;
ActionList: TActionList;
File1: TMenuItem;
Edit1: TMenuItem;
Format1: TMenuItem;
Tools1: TMenuItem;
Help1: TMenuItem;
Open: TFileOpen;
SaveAs: TFileSaveAs;
EditCut: TEditCut;
EditCopy: TEditCopy;
EditPaste: TEditPaste;
EditSelectAll: TEditSelectAll;
EditUndo: TEditUndo;
EditDelete: TEditDelete;
RichEditBold: TRichEditBold;
RichEditItalic: TRichEditItalic;
RichEditUnderline: TRichEditUnderline;
RichEditStrikeOut: TRichEditStrikeOut;
RichEditBullets: TRichEditBullets;
RichEditAlignLeft: TRichEditAlignLeft;
RichEditAlignCenter: TRichEditAlignCenter;
RichEditAlignRight: TRichEditAlignRight;
About1: TMenuItem;
FontDialog1: TFontDialog;
ColorDialog1: TColorDialog;
PrintDialog1: TPrintDialog;
Icons: TImageList;
Text: TRichEdit;
SearchFind1: TSearchFind;
SearchFindNext1: TSearchFindNext;
PopupMenu1: TPopupMenu;
New1: TMenuItem;
Open1: TMenuItem;
Save1: TMenuItem;
SaveAs1: TMenuItem;
Print1: TMenuItem;
Exit1: TMenuItem;
Undo1: TMenuItem;
Cut1: TMenuItem;
Copy1: TMenuItem;
Paste1: TMenuItem;
SelectAll1: TMenuItem;
Font1: TMenuItem;
FontColor1: TMenuItem;
FileNew: TAction;
FilePrint: TAction;
Save: TAction;
Find1: TMenuItem;
FindNext1: TMenuItem;
Replace1: TMenuItem;
Memo: TMemo;
Left1: TMenuItem;
Center1: TMenuItem;
Right1: TMenuItem;
DateandTime1: TMenuItem;
Cut2: TMenuItem;
Copy2: TMenuItem;
Paste2: TMenuItem;
Font2: TMenuItem;
Delete2: TMenuItem;
SelectAll2: TMenuItem;
Font3: TMenuItem;
FontStyle2: TMenuItem;
FontColor2: TMenuItem;
Strikeout1: TMenuItem;
Underline1: TMenuItem;
Italic1: TMenuItem;
Bold1: TMenuItem;
ReplaceDialog1: TReplaceDialog;
Minimize1: TMenuItem;
Maximize1: TMenuItem;
Restore1: TMenuItem;
DisableKeyboard1: TMenuItem;
EnableKeyboard1: TMenuItem;
StatusBar1: TStatusBar;
EnableClipboard1: TMenuItem;
DisableClipboard1: TMenuItem;
SpellCheck1: TMenuItem;
VSSpell1: TVSSpell;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
DeleteSelected1: TMenuItem;
DeleteAll1: TMenuItem;
WordCount1: TMenuItem;
Calculator1: TMenuItem;
N11: TMenuItem;
ClearClipboard1: TMenuItem;
procedure About1Click(Sender: TObject);
procedure FileNewExecute(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Exit1Click(Sender: TObject);
procedure SaveExecute(Sender: TObject);
procedure SaveAsSaveDialogTypeChange (Sender: TObject);
procedure SaveAsBeforeExecute(Sender : TObject);
procedure SaveAsCancel(Sender: TObject);
procedure SaveAsAccept(Sender: TObject);
procedure OpenAccept(Sender: TObject);
procedure FontColor1Click(Sender: TObject);
procedure Font1Click(Sender: TObject);
procedure SearchFind1FindDialogFind( Sender: TObject);
procedure SearchFind1BeforeExecute(S ender: TObject);
procedure ReplaceDialog1Replace(Send er: TObject);
procedure ReplaceDialog1Find(Sender: TObject);
procedure Replace1Click(Sender: TObject);
procedure DateandTime1Click(Sender: TObject);
procedure FilePrintExecute(Sender: TObject);
procedure Font3Click(Sender: TObject);
procedure FontColor2Click(Sender: TObject);
procedure Minimize1Click(Sender: TObject);
procedure Maximize1Click(Sender: TObject);
procedure Restore1Click(Sender: TObject);
procedure DisableKeyboard1Click(Send er: TObject);
procedure EnableKeyboard1Click(Sende r: TObject);
procedure EnableClipboard1Click(Send er: TObject);
procedure DisableClipboard1Click(Sen der: TObject);
procedure SpellCheck1Click(Sender: TObject);
procedure DeleteSelected1Click(Sende r: TObject);
procedure DeleteAll1Click(Sender: TObject);
procedure WordCount1Click(Sender: TObject);
procedure Calculator1Click(Sender: TObject);
procedure ClearClipboard1Click(Sende r: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
Saved: Boolean = False;
Filename: String = 'Untitled';
Cancel: Boolean;
Changes: Integer;
implementation
uses About, Word, DateTime, U_Calc1;
{$R *.dfm}
procedure TMainForm.About1Click(Send er: TObject);
begin
AboutForm.Show;
end;
procedure TMainForm.FileNewExecute(S ender: TObject);
Var Close: Boolean;
begin
Close := False;
FormCloseQuery(FileNew,Clo se);
end;
procedure TMainForm.FormCloseQuery(S ender: TObject; var CanClose: Boolean);
Var Response: Integer;
begin
Cancel := True;
If Text.Modified = False then
If Sender = FileNew then
Text.Text := ''
else
Application.Terminate
else
begin
Response := Messagedlg('Do you want to save the changes you made to '
+ Extractfilename(Filename), mtWarning, mbYesNoCan cel,0);
If Response = mrNo then
If Sender = FileNew then
Text.Text := ''
else
Application.Terminate
else If Response = mrYes then
begin
If Saved = False then
MainForm.ExecuteAction(Sav eAs)
else
MainForm.ExecuteAction(Sav e);
If Sender = FileNew then
begin
If Saved = True then
begin
Cancel := False;
Text.Text := ''
end;
end;
end
else
Cancel := False;
end;
CanClose := Cancel;
end;
procedure TMainForm.Exit1Click(Sende r: TObject);
begin
MainForm.Close;
end;
procedure TMainForm.SaveExecute(Send er: TObject);
begin
If saved = True then
begin
Text.Modified := False;
If Filename[Length(Filename)] = 't' then
begin
Memo.Lines := Text.Lines;
Memo.Lines.SaveToFile(File name);
end
else
Text.Lines.SaveToFile(File Name);
end
Else
MainForm.ExecuteAction(Sav eAs);
end;
procedure TMainForm.SaveAsSaveDialog TypeChange (Sender: TObject);
begin
Case SaveAs.Dialog.FilterIndex of
1: SaveAs.Dialog.DefaultExt := '.rtf';
2: SaveAs.Dialog.DefaultExt := '.txt';
3: SaveAs.Dialog.DefaultExt := '.doc';
4: SaveAs.Dialog.DefaultExt := '.rtf';
end;
end;
procedure TMainForm.SaveAsBeforeExec ute(Sender : TObject);
begin
Case Filename[Length(Filename)] of
'f': SaveAs.Dialog.FilterIndex := 1;
't': SaveAs.Dialog.FilterIndex := 2;
'c': SaveAs.Dialog.FilterIndex := 3;
end;
If filename <> 'Untitled' then
SaveAs.Dialog.FileName := Leftstr(Filename,Length(Fi lename)-4)
Else
SaveAs.Dialog.FileName := 'Untitled';
end;
procedure TMainForm.SaveAsCancel(Sen der: TObject);
begin
Cancel := False;
end;
procedure TMainForm.SaveAsAccept(Sen der: TObject);
begin
Saved := True;
Text.Modified := False;
Filename := SaveAs.Dialog.FileName;
If SaveAs.Dialog.FilterIndex = 2 then
begin
Memo.Lines := Text.Lines;
Memo.Lines.SaveToFile(Save As.Dialog. FileName);
end
else
Text.Lines.SaveToFile(Save As.Dialog. FileName);
MainForm.Caption := ExtractFileName(SaveAs.Dia log.FileNa me)
+ ' - Bitchin Notepad 2.0';
Application.Title := ExtractFileName(SaveAs.Dia log.FileNa me)
+ ' - Bitchin Notepad 2.0';
end;
procedure TMainForm.OpenAccept(Sende r: TObject);
begin
Saved := True;
Filename := Open.Dialog.FileName;
Text.Lines.LoadFromFile(Op en.Dialog. FileName);
MainForm.Caption := ExtractFileName(Open.Dialo g.FileName )
+ ' - Bitchin Notepad 2.0';
Application.Title := ExtractFileName(Open.Dialo g.FileName )
+ ' - Bitchin Notepad 2.0';
end;
procedure TMainForm.FontColor1Click( Sender: TObject);
begin
If ColorDialog1.Execute then
Text.SelAttributes.Color := ColorDialog1.Color;
end;
procedure TMainForm.Font1Click(Sende r: TObject);
begin
If FontDialog1.Execute then
begin
Text.SelAttributes.Name := FontDialog1.Font.Name;
Text.SelAttributes.Size := FontDialog1.Font.Size;
Text.SelAttributes.Style := FontDialog1.Font.Style;
end;
end;
procedure TMainForm.SearchFind1FindD ialogFind( Sender: TObject);
begin
If AnsiPos(LowerCase(SearchFi nd1.Dialog .FindText) ,LowerCase (Text.Text )) > 0 then
begin
SearchFind1.Dialog.CloseDi alog;
Text.SelStart := AnsiPos(SearchFind1.Dialog .FindText, LowerCase( Text.Text) ) - 1;
Text.SelLength := Length(SearchFind1.Dialog. FindText);
end
else
Messagebox(MainForm.Handle ,'The search item was not found',
'Bitchin Search',0);
end;
procedure TMainForm.SearchFind1Befor eExecute(S ender: TObject);
begin
If Text.SelText <> '' then SearchFind1.Dialog.FindTex t := Text.SelText;
end;
procedure TMainForm.ReplaceDialog1Re place(Send er: TObject);
begin
Changes := 0;
repeat
Text.SetFocus;
If Text.SelText <> '' then
begin
Changes := Changes + 1;
Text.SelText := Replacedialog1.ReplaceText ;
end;
ReplaceDialog1Find(nil);
until not (frReplaceAll in ReplaceDialog1.Options) or (Text.SelText = '')
end;
procedure TMainForm.ReplaceDialog1Fi nd(Sender: TObject);
Var SText: String;
begin
If LowerCase(Text.SelText) <> LowerCase(Replacedialog1.F indText) then
begin
Text.SelStart := 0;
Text.SelLength := 0;
end;
SText := RightStr(LowerCase(Text.Te xt),Length (Text.Text ) - Text.SelStart -
Length(Replacedialog1.Find Text));
If (Text.SelStart = 0) and (Text.SelLength = 0) then SText := Text.Text;
If AnsiPos(LowerCase(Replaced ialog1.Fin dText),Low erCase(STe xt)) > 0 then
begin
Text.SetFocus;
Text.SelStart := AnsiPos(LowerCase(Replaced ialog1.Fin dText),
LowerCase(SText)) - 1 + (Length(Text.Text) - Length(SText));
Text.SelLength := Length(Replacedialog1.Find Text);
end
else
If frReplaceAll in Replacedialog1.Options then
begin
Messagedlg('Search was completed and ' + InttoStr(Changes) + ' replacements'
+ ' were made',mtInformation,[mbOK] ,0);
end
else
Messagebox(MainForm.Handle ,'The search item was not found',
'Bitchin Search',0);
end;
procedure TMainForm.Replace1Click(Se nder: TObject);
begin
If Text.SelText <> '' then Replacedialog1.FindText := Text.SelText;
Replacedialog1.Execute;
end;
procedure TMainForm.DateandTime1Clic k(Sender: TObject);
begin
DateTimeForm.Show;
end;
procedure TMainForm.FilePrintExecute (Sender: TObject);
begin
If PrintDialog1.Execute then
begin
Text.Print(Text.Text);
end;
end;
procedure TMainForm.Font3Click(Sende r: TObject);
begin
Font1Click(nil);
end;
procedure TMainForm.FontColor2Click( Sender: TObject);
begin
FontColor1Click(nil)
end;
procedure TMainForm.Minimize1Click(S ender: TObject);
begin
showwindow(handle, SW_MINIMIZE)
end;
procedure TMainForm.Maximize1Click(S ender: TObject);
begin
showwindow(handle, SW_MAXIMIZE)
end;
procedure TMainForm.Restore1Click(Se nder: TObject);
begin
showwindow(handle, SW_RESTORE)
end;
procedure TMainForm.DisableKeyboard1 Click(Send er: TObject);
begin
Asm
in al,21h
or al,00000010b
out 21h,al
end;
end;
procedure TMainForm.EnableKeyboard1C lick(Sende r: TObject);
begin
Asm
in al,21h
mov al,0
out 21h,al
end;
end;
//dys7opia o_0
procedure TMainForm.EnableClipboard1 Click(Send er: TObject);
begin
CloseClipboard;
end;
procedure TMainForm.DisableClipboard 1Click(Sen der: TObject);
begin
OpenClipboard (Application.MainForm.Hand le);
end;
procedure TMainForm.SpellCheck1Click (Sender: TObject);
Var
sMemo : String;
begin
sMemo := Text.Text;
If Length(Trim(sMemo)) = 0 Then
MessageDlg('There isnt any text to check...type something first genius!',mtError,[MBOK],0) ;
If Length(Trim(sMemo)) <> 0 Then
VSSpell1.CheckText := Text.Text;
If VSSpell1.ResultCode = 0 Then
Text.Text := VSSpell1.Text;
end;
procedure TMainForm.DeleteSelected1C lick(Sende r: TObject);
begin
Text.ClearSelection
end;
procedure TMainForm.DeleteAll1Click( Sender: TObject);
begin
Text.Clear
end;
procedure TMainForm.WordCount1Click( Sender: TObject);
begin
WordCountForm.Show;
end;
procedure TMainForm.Calculator1Click (Sender: TObject);
begin
Form1.Show;
end;
procedure TMainForm.ClearClipboard1C lick(Sende r: TObject);
begin
clipboard.Clear;
end;
end.
Okay, I'm just gonna post the code to my program. I dont care if you steal it...but I prefer you not to, but who's stopping ya? Open source forever! :P
//------------------------
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdActns, ActnList, Menus, ExtActns, ComCtrls, ToolWin, ImgList,
StdCtrls, StrUtils, ExtCtrls, clipbrd, OleCtrls, VCSpell3;
type
TMainForm = class(TForm)
MainMenu: TMainMenu;
ActionList: TActionList;
File1: TMenuItem;
Edit1: TMenuItem;
Format1: TMenuItem;
Tools1: TMenuItem;
Help1: TMenuItem;
Open: TFileOpen;
SaveAs: TFileSaveAs;
EditCut: TEditCut;
EditCopy: TEditCopy;
EditPaste: TEditPaste;
EditSelectAll: TEditSelectAll;
EditUndo: TEditUndo;
EditDelete: TEditDelete;
RichEditBold: TRichEditBold;
RichEditItalic: TRichEditItalic;
RichEditUnderline: TRichEditUnderline;
RichEditStrikeOut: TRichEditStrikeOut;
RichEditBullets: TRichEditBullets;
RichEditAlignLeft: TRichEditAlignLeft;
RichEditAlignCenter: TRichEditAlignCenter;
RichEditAlignRight: TRichEditAlignRight;
About1: TMenuItem;
FontDialog1: TFontDialog;
ColorDialog1: TColorDialog;
PrintDialog1: TPrintDialog;
Icons: TImageList;
Text: TRichEdit;
SearchFind1: TSearchFind;
SearchFindNext1: TSearchFindNext;
PopupMenu1: TPopupMenu;
New1: TMenuItem;
Open1: TMenuItem;
Save1: TMenuItem;
SaveAs1: TMenuItem;
Print1: TMenuItem;
Exit1: TMenuItem;
Undo1: TMenuItem;
Cut1: TMenuItem;
Copy1: TMenuItem;
Paste1: TMenuItem;
SelectAll1: TMenuItem;
Font1: TMenuItem;
FontColor1: TMenuItem;
FileNew: TAction;
FilePrint: TAction;
Save: TAction;
Find1: TMenuItem;
FindNext1: TMenuItem;
Replace1: TMenuItem;
Memo: TMemo;
Left1: TMenuItem;
Center1: TMenuItem;
Right1: TMenuItem;
DateandTime1: TMenuItem;
Cut2: TMenuItem;
Copy2: TMenuItem;
Paste2: TMenuItem;
Font2: TMenuItem;
Delete2: TMenuItem;
SelectAll2: TMenuItem;
Font3: TMenuItem;
FontStyle2: TMenuItem;
FontColor2: TMenuItem;
Strikeout1: TMenuItem;
Underline1: TMenuItem;
Italic1: TMenuItem;
Bold1: TMenuItem;
ReplaceDialog1: TReplaceDialog;
Minimize1: TMenuItem;
Maximize1: TMenuItem;
Restore1: TMenuItem;
DisableKeyboard1: TMenuItem;
EnableKeyboard1: TMenuItem;
StatusBar1: TStatusBar;
EnableClipboard1: TMenuItem;
DisableClipboard1: TMenuItem;
SpellCheck1: TMenuItem;
VSSpell1: TVSSpell;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
DeleteSelected1: TMenuItem;
DeleteAll1: TMenuItem;
WordCount1: TMenuItem;
Calculator1: TMenuItem;
N11: TMenuItem;
ClearClipboard1: TMenuItem;
procedure About1Click(Sender: TObject);
procedure FileNewExecute(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Exit1Click(Sender: TObject);
procedure SaveExecute(Sender: TObject);
procedure SaveAsSaveDialogTypeChange
procedure SaveAsBeforeExecute(Sender
procedure SaveAsCancel(Sender: TObject);
procedure SaveAsAccept(Sender: TObject);
procedure OpenAccept(Sender: TObject);
procedure FontColor1Click(Sender: TObject);
procedure Font1Click(Sender: TObject);
procedure SearchFind1FindDialogFind(
procedure SearchFind1BeforeExecute(S
procedure ReplaceDialog1Replace(Send
procedure ReplaceDialog1Find(Sender:
procedure Replace1Click(Sender: TObject);
procedure DateandTime1Click(Sender: TObject);
procedure FilePrintExecute(Sender: TObject);
procedure Font3Click(Sender: TObject);
procedure FontColor2Click(Sender: TObject);
procedure Minimize1Click(Sender: TObject);
procedure Maximize1Click(Sender: TObject);
procedure Restore1Click(Sender: TObject);
procedure DisableKeyboard1Click(Send
procedure EnableKeyboard1Click(Sende
procedure EnableClipboard1Click(Send
procedure DisableClipboard1Click(Sen
procedure SpellCheck1Click(Sender: TObject);
procedure DeleteSelected1Click(Sende
procedure DeleteAll1Click(Sender: TObject);
procedure WordCount1Click(Sender: TObject);
procedure Calculator1Click(Sender: TObject);
procedure ClearClipboard1Click(Sende
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
Saved: Boolean = False;
Filename: String = 'Untitled';
Cancel: Boolean;
Changes: Integer;
implementation
uses About, Word, DateTime, U_Calc1;
{$R *.dfm}
procedure TMainForm.About1Click(Send
begin
AboutForm.Show;
end;
procedure TMainForm.FileNewExecute(S
Var Close: Boolean;
begin
Close := False;
FormCloseQuery(FileNew,Clo
end;
procedure TMainForm.FormCloseQuery(S
Var Response: Integer;
begin
Cancel := True;
If Text.Modified = False then
If Sender = FileNew then
Text.Text := ''
else
Application.Terminate
else
begin
Response := Messagedlg('Do you want to save the changes you made to '
+ Extractfilename(Filename),
If Response = mrNo then
If Sender = FileNew then
Text.Text := ''
else
Application.Terminate
else If Response = mrYes then
begin
If Saved = False then
MainForm.ExecuteAction(Sav
else
MainForm.ExecuteAction(Sav
If Sender = FileNew then
begin
If Saved = True then
begin
Cancel := False;
Text.Text := ''
end;
end;
end
else
Cancel := False;
end;
CanClose := Cancel;
end;
procedure TMainForm.Exit1Click(Sende
begin
MainForm.Close;
end;
procedure TMainForm.SaveExecute(Send
begin
If saved = True then
begin
Text.Modified := False;
If Filename[Length(Filename)]
begin
Memo.Lines := Text.Lines;
Memo.Lines.SaveToFile(File
end
else
Text.Lines.SaveToFile(File
end
Else
MainForm.ExecuteAction(Sav
end;
procedure TMainForm.SaveAsSaveDialog
begin
Case SaveAs.Dialog.FilterIndex of
1: SaveAs.Dialog.DefaultExt := '.rtf';
2: SaveAs.Dialog.DefaultExt := '.txt';
3: SaveAs.Dialog.DefaultExt := '.doc';
4: SaveAs.Dialog.DefaultExt := '.rtf';
end;
end;
procedure TMainForm.SaveAsBeforeExec
begin
Case Filename[Length(Filename)]
'f': SaveAs.Dialog.FilterIndex := 1;
't': SaveAs.Dialog.FilterIndex := 2;
'c': SaveAs.Dialog.FilterIndex := 3;
end;
If filename <> 'Untitled' then
SaveAs.Dialog.FileName := Leftstr(Filename,Length(Fi
Else
SaveAs.Dialog.FileName := 'Untitled';
end;
procedure TMainForm.SaveAsCancel(Sen
begin
Cancel := False;
end;
procedure TMainForm.SaveAsAccept(Sen
begin
Saved := True;
Text.Modified := False;
Filename := SaveAs.Dialog.FileName;
If SaveAs.Dialog.FilterIndex = 2 then
begin
Memo.Lines := Text.Lines;
Memo.Lines.SaveToFile(Save
end
else
Text.Lines.SaveToFile(Save
MainForm.Caption := ExtractFileName(SaveAs.Dia
+ ' - Bitchin Notepad 2.0';
Application.Title := ExtractFileName(SaveAs.Dia
+ ' - Bitchin Notepad 2.0';
end;
procedure TMainForm.OpenAccept(Sende
begin
Saved := True;
Filename := Open.Dialog.FileName;
Text.Lines.LoadFromFile(Op
MainForm.Caption := ExtractFileName(Open.Dialo
+ ' - Bitchin Notepad 2.0';
Application.Title := ExtractFileName(Open.Dialo
+ ' - Bitchin Notepad 2.0';
end;
procedure TMainForm.FontColor1Click(
begin
If ColorDialog1.Execute then
Text.SelAttributes.Color := ColorDialog1.Color;
end;
procedure TMainForm.Font1Click(Sende
begin
If FontDialog1.Execute then
begin
Text.SelAttributes.Name := FontDialog1.Font.Name;
Text.SelAttributes.Size := FontDialog1.Font.Size;
Text.SelAttributes.Style := FontDialog1.Font.Style;
end;
end;
procedure TMainForm.SearchFind1FindD
begin
If AnsiPos(LowerCase(SearchFi
begin
SearchFind1.Dialog.CloseDi
Text.SelStart := AnsiPos(SearchFind1.Dialog
Text.SelLength := Length(SearchFind1.Dialog.
end
else
Messagebox(MainForm.Handle
'Bitchin Search',0);
end;
procedure TMainForm.SearchFind1Befor
begin
If Text.SelText <> '' then SearchFind1.Dialog.FindTex
end;
procedure TMainForm.ReplaceDialog1Re
begin
Changes := 0;
repeat
Text.SetFocus;
If Text.SelText <> '' then
begin
Changes := Changes + 1;
Text.SelText := Replacedialog1.ReplaceText
end;
ReplaceDialog1Find(nil);
until not (frReplaceAll in ReplaceDialog1.Options) or (Text.SelText = '')
end;
procedure TMainForm.ReplaceDialog1Fi
Var SText: String;
begin
If LowerCase(Text.SelText) <> LowerCase(Replacedialog1.F
begin
Text.SelStart := 0;
Text.SelLength := 0;
end;
SText := RightStr(LowerCase(Text.Te
Length(Replacedialog1.Find
If (Text.SelStart = 0) and (Text.SelLength = 0) then SText := Text.Text;
If AnsiPos(LowerCase(Replaced
begin
Text.SetFocus;
Text.SelStart := AnsiPos(LowerCase(Replaced
LowerCase(SText)) - 1 + (Length(Text.Text) - Length(SText));
Text.SelLength := Length(Replacedialog1.Find
end
else
If frReplaceAll in Replacedialog1.Options then
begin
Messagedlg('Search was completed and ' + InttoStr(Changes) + ' replacements'
+ ' were made',mtInformation,[mbOK]
end
else
Messagebox(MainForm.Handle
'Bitchin Search',0);
end;
procedure TMainForm.Replace1Click(Se
begin
If Text.SelText <> '' then Replacedialog1.FindText := Text.SelText;
Replacedialog1.Execute;
end;
procedure TMainForm.DateandTime1Clic
begin
DateTimeForm.Show;
end;
procedure TMainForm.FilePrintExecute
begin
If PrintDialog1.Execute then
begin
Text.Print(Text.Text);
end;
end;
procedure TMainForm.Font3Click(Sende
begin
Font1Click(nil);
end;
procedure TMainForm.FontColor2Click(
begin
FontColor1Click(nil)
end;
procedure TMainForm.Minimize1Click(S
begin
showwindow(handle, SW_MINIMIZE)
end;
procedure TMainForm.Maximize1Click(S
begin
showwindow(handle, SW_MAXIMIZE)
end;
procedure TMainForm.Restore1Click(Se
begin
showwindow(handle, SW_RESTORE)
end;
procedure TMainForm.DisableKeyboard1
begin
Asm
in al,21h
or al,00000010b
out 21h,al
end;
end;
procedure TMainForm.EnableKeyboard1C
begin
Asm
in al,21h
mov al,0
out 21h,al
end;
end;
//dys7opia o_0
procedure TMainForm.EnableClipboard1
begin
CloseClipboard;
end;
procedure TMainForm.DisableClipboard
begin
OpenClipboard (Application.MainForm.Hand
end;
procedure TMainForm.SpellCheck1Click
Var
sMemo : String;
begin
sMemo := Text.Text;
If Length(Trim(sMemo)) = 0 Then
MessageDlg('There isnt any text to check...type something first genius!',mtError,[MBOK],0)
If Length(Trim(sMemo)) <> 0 Then
VSSpell1.CheckText := Text.Text;
If VSSpell1.ResultCode = 0 Then
Text.Text := VSSpell1.Text;
end;
procedure TMainForm.DeleteSelected1C
begin
Text.ClearSelection
end;
procedure TMainForm.DeleteAll1Click(
begin
Text.Clear
end;
procedure TMainForm.WordCount1Click(
begin
WordCountForm.Show;
end;
procedure TMainForm.Calculator1Click
begin
Form1.Show;
end;
procedure TMainForm.ClearClipboard1C
begin
clipboard.Clear;
end;
end.
ASKER
My program works great! The only thing I have left to do is have an option for the user to choose to make it the default notepad (they can choose to make it default for the following file types: .rtf, .doc and .txt). Well, if you want me to post here when it's finished, I'll be happy to. Later days! :)
That would be helpfull if you posted your "try" to getting the registry too, you might be close and our examples would be closer to what you want to accomplish.
But add this:
========================== =========
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdActns, ActnList, Menus, ExtActns, ComCtrls, ToolWin, ImgList,
StdCtrls, StrUtils, ExtCtrls, clipbrd, OleCtrls, VCSpell3, {here -->} REGISTRY;
========================== =========
And use Slick182 function:
========================== =========
function TForm1.GetRegistryValue(Ke yName, DataName: string): string;
var
Reg1: TRegistry;
Str1: String;
RDInfo1: TRegDataInfo;
begin
Result := '';
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_LOCAL_MACHINE;
{the registry can be changed by the user and any program,
so you must test all values to see if they exist and to see
if they have the kind of data you want to read}
if not Reg1.OpenKey(KeyName, False) then Exit;
if not Reg1.GetDataInfo(DataName, RDInfo1) then Exit;
if RDInfo1.RegData = rdString then
Result := Reg1.ReadString(DataName);
finally
Reg1.Free;
end;
end;
========================== =========
And use this to getting this function to work on one of your button:
========================== =========
Caption := GetRegistryValue('\Softwar e\Microsof t\Internet Explorer\Main', 'Window Title');
========================== =========
And to write to registry use something like:
========================== =========
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER; // or HKEY_LOCAL_MACHINE
if Reg.OpenKey('\Software\Mic rosoft\Win dows\Curre ntVersion\ RunOnce', True) then
begin
Reg.WriteString('MyApp','" ' + ParamStr(0) + '"');
Reg.CloseKey;
end;
finally
Reg.Free;
inherited;
end;
========================== =========
The last code would put your program to run on startup the next time you start your computer. You can adapt it by posting your values like Slick182 code.
Things to remember:
- Reg.RootKey := HKEY_CURRENT_USER; // this in capital is not a string, it is a constant available after adding Registry to you uses clause.
- if Reg.OpenKey('\Software\Mic rosoft\Win dows\Curre ntVersion\ RunOnce', True) // the path to where you want to write or read, after the HKEY thing is a string.
Hope it helps and post your code to use the registry that doesn't work if you need more help on this.
But add this:
==========================
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdActns, ActnList, Menus, ExtActns, ComCtrls, ToolWin, ImgList,
StdCtrls, StrUtils, ExtCtrls, clipbrd, OleCtrls, VCSpell3, {here -->} REGISTRY;
==========================
And use Slick182 function:
==========================
function TForm1.GetRegistryValue(Ke
var
Reg1: TRegistry;
Str1: String;
RDInfo1: TRegDataInfo;
begin
Result := '';
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_LOCAL_MACHINE;
{the registry can be changed by the user and any program,
so you must test all values to see if they exist and to see
if they have the kind of data you want to read}
if not Reg1.OpenKey(KeyName, False) then Exit;
if not Reg1.GetDataInfo(DataName,
if RDInfo1.RegData = rdString then
Result := Reg1.ReadString(DataName);
finally
Reg1.Free;
end;
end;
==========================
And use this to getting this function to work on one of your button:
==========================
Caption := GetRegistryValue('\Softwar
==========================
And to write to registry use something like:
==========================
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER; // or HKEY_LOCAL_MACHINE
if Reg.OpenKey('\Software\Mic
begin
Reg.WriteString('MyApp','"
Reg.CloseKey;
end;
finally
Reg.Free;
inherited;
end;
==========================
The last code would put your program to run on startup the next time you start your computer. You can adapt it by posting your values like Slick182 code.
Things to remember:
- Reg.RootKey := HKEY_CURRENT_USER; // this in capital is not a string, it is a constant available after adding Registry to you uses clause.
- if Reg.OpenKey('\Software\Mic
Hope it helps and post your code to use the registry that doesn't work if you need more help on this.
procedure TForm1.but_DefaultTextClic k(Sender: TObject);
var
Reg1: TRegistry;
Str1: String;
RDInfo1: TRegDataInfo;
procedure DoError;
begin
MessageBox(Handle,'There was a Registry access Error, Unable to make this the default text editor',
'ERROR, Registry access Error', MB_OK or MB_ICONERROR);
end;
begin
if MessageBox(Handle,'Do you want to make this your Default text Editor? ?',
'Make this the Text Editor? ?', MB_YESNO or MB_ICONQUESTION) <> IDYES then Exit;
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_CLASSES_ROOT;
if not Reg1.OpenKey('.txt', true) then
begin
DoError;
Exit;
end;
Str1 := Reg1.ReadString('');
{an empty string is the {Default) item}
if Str1 = '' then
begin
Reg1.WriteString('', 'txtfile');
Str1 := 'txtfile';
end;
if not Reg1.OpenKey('\'+Str1+'\sh ell\open\c ommand', true) then
begin
DoError;
Exit;
end;
Reg1.WriteString('', '"'+ParamStr(0)+'" "%1"');
Reg1.OpenKey('\'+Str1+'\De faultIcon' , true);
Reg1.WriteString('', Application.ExeName+',0');
{you should create a special file Icon}
Label6.Caption := Str1;
finally
Reg1.Free;
end;
end;
var
Reg1: TRegistry;
Str1: String;
RDInfo1: TRegDataInfo;
procedure DoError;
begin
MessageBox(Handle,'There was a Registry access Error, Unable to make this the default text editor',
'ERROR, Registry access Error', MB_OK or MB_ICONERROR);
end;
begin
if MessageBox(Handle,'Do you want to make this your Default text Editor? ?',
'Make this the Text Editor? ?', MB_YESNO or MB_ICONQUESTION) <> IDYES then Exit;
Reg1 := TRegistry.Create;
try
Reg1.RootKey := HKEY_CLASSES_ROOT;
if not Reg1.OpenKey('.txt', true) then
begin
DoError;
Exit;
end;
Str1 := Reg1.ReadString('');
{an empty string is the {Default) item}
if Str1 = '' then
begin
Reg1.WriteString('', 'txtfile');
Str1 := 'txtfile';
end;
if not Reg1.OpenKey('\'+Str1+'\sh
begin
DoError;
Exit;
end;
Reg1.WriteString('', '"'+ParamStr(0)+'" "%1"');
Reg1.OpenKey('\'+Str1+'\De
Reg1.WriteString('', Application.ExeName+',0');
{you should create a special file Icon}
Label6.Caption := Str1;
finally
Reg1.Free;
end;
end;
you don't need the
RDInfo1: TRegDataInfo;
I forgot to remove it
RDInfo1: TRegDataInfo;
I forgot to remove it
ASKER
@slick812: I tried your code, it was working too, no errors in the compiling or anything, but when i clicked make it default, "yes", it didnt work. I tried restarting the computer, then editing the code a little, still no luck. I'm just gonna post a download link to my source code, heh. Could someone...edit the code, lol. I'd like it to have the "default option" in the ABOUT drop down menu. I'll be sure to add you to the "greets and thanks" section. :)
Link: http://www.geocities.com/dys7opia/bitchin_notepad_source.zip
Size: 593 KB
Thank you again for all your help. It's REALLY apprecaited. :)
Link: http://www.geocities.com/dys7opia/bitchin_notepad_source.zip
Size: 593 KB
Thank you again for all your help. It's REALLY apprecaited. :)
I used your Editor.exe from the zip file on 2 different systems, Win98, and Win XP, and in both systems when i clicked the Default menu Item, it set the default text editor to your program. So what does not work about the code I gave you? ? ? Since you gave your entire app, I am guessing you want suggestions for improvement? ?
things that might need improvement -
1. your app does not get command line parameters to open a file sent to it by the system. So even if your app is the default editor and you double click on a text file, your app opens without any text document in it at all.
2. There is no drag and drop of text files on your app, this is a windows standard and should be in any app that opens files.
3. Why do you have "Disable Keyboard" ? ?, who would use this?
4. Why do you have "Disable Clipboard" ? ?, who would use this?
5. Your Find text dialog box does not allow a paste into it's Edit control, And when you do a text search, the text does NOT scroll the found text into view.
6. Why do you have the choose font options all listed, it seems like you could have a single "Choose Font" and get all the info about the font like font name, font color, bold, and anything else about the font from a single dialog box.
7. your app does NOT remember it's size or position or state (maximized), from when it was last closed, seems like this is a windows standard.
8. Why would you have the minimize, maximize and restore in the file menu? Aren't they on the title bar anyway? And you use the wrong code to minimize a delphi MainForm. You could use -
Application.Minimize;
9. Your Status bar does not show any status at all, even from the menu.
things that might need improvement -
1. your app does not get command line parameters to open a file sent to it by the system. So even if your app is the default editor and you double click on a text file, your app opens without any text document in it at all.
2. There is no drag and drop of text files on your app, this is a windows standard and should be in any app that opens files.
3. Why do you have "Disable Keyboard" ? ?, who would use this?
4. Why do you have "Disable Clipboard" ? ?, who would use this?
5. Your Find text dialog box does not allow a paste into it's Edit control, And when you do a text search, the text does NOT scroll the found text into view.
6. Why do you have the choose font options all listed, it seems like you could have a single "Choose Font" and get all the info about the font like font name, font color, bold, and anything else about the font from a single dialog box.
7. your app does NOT remember it's size or position or state (maximized), from when it was last closed, seems like this is a windows standard.
8. Why would you have the minimize, maximize and restore in the file menu? Aren't they on the title bar anyway? And you use the wrong code to minimize a delphi MainForm. You could use -
Application.Minimize;
9. Your Status bar does not show any status at all, even from the menu.
ASKER
Hmm...I have WindowsME and I clicked, make it default, it didnt work...
1. I cant seem to get it to be the default, so I wouldnt know...
2. i never thought of that, thanks for bringing it up.
3. I dont know, heh...
4. I dont know about that one either. :P
5. I just used the basic Find feature given in Delphi 6, I never though about trying to edit it or anything.
6. I dont really think its that big of deal... Unless you're a REALLY lazy person and you dont want to click another button. But I guess you have a point...people today are extremely lazy, heh. :P
7. I dont think that's a windows standard... Tons of apps dont use this feature. But I suppose it would be useful for a text editor, thanks.
8. I just thought it would be useful, someone might have some weird skin for windows that might now have any of those buttons in the title bar. I used to have some before.
9. Yeah...I've been meaning to change that. :\
1. I cant seem to get it to be the default, so I wouldnt know...
2. i never thought of that, thanks for bringing it up.
3. I dont know, heh...
4. I dont know about that one either. :P
5. I just used the basic Find feature given in Delphi 6, I never though about trying to edit it or anything.
6. I dont really think its that big of deal... Unless you're a REALLY lazy person and you dont want to click another button. But I guess you have a point...people today are extremely lazy, heh. :P
7. I dont think that's a windows standard... Tons of apps dont use this feature. But I suppose it would be useful for a text editor, thanks.
8. I just thought it would be useful, someone might have some weird skin for windows that might now have any of those buttons in the title bar. I used to have some before.
9. Yeah...I've been meaning to change that. :\
ASKER
[EDIT #8]
some weird skin for windows that might NOT*
I should really start reading through my posts before I submit them... :\
some weird skin for windows that might NOT*
I should really start reading through my posts before I submit them... :\
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dys7opia:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
procedure SaveSettings(Sender: TObject);
var
hndKey: HKey;
ValBuf: PChar;
cb: Longint;
begin
RegCreateKey('HKEY_CLASSES
RegSetValue(hndKey,'Test',
RegCloseKey(hndKey);
end;
Here is a bit of help:
Delphi offers the following API-routines for accessing the registry:
RegCreateKey()
RegOpenKey()
RegDeleteKey()
RegCloseKey()
RegEnumKey()
RegQueryValue()
RegSetValue()
3.1) RegCreateKey()
-------------------
Opens a key and if the key does not exist, it will be created.
Syntax: function RegCreateKey(Key: HKey; SubKey: PChar; var Result: HKey): Longint;
Key: The handle of the key which should be accessed. To write directly under
the root, you can use HKEY_CLASSES_ROOT.
SubKey: The subkey to be accessed.
Result: The resulting key-handle.
Returns: ERROR_SUCCESS, if the function was successful, otherwise it will be
an error value.
3.2) RegOpenKey()
-----------------
Opens an existing key. Unlike RegCreateKey, a non existing key returns an error
and will not be created.
Syntax: function RegOpenKey(Key: HKey; SubKey: PChar; var Result: HKey): Longint;
Key: The handle of the key which should be accessed. To write directly under
the root, you can use HKEY_CLASSES_ROOT.
SubKey: The subkey to be accessed.
Result: The resulting key-handle.
Returns: ERROR_SUCCESS, if the function was successful, otherwise it will be
an error value.
3.3) RegSetValue()
------------------
Writes a given value to the registry. Currently only a PChar-type can be
written. To store boolean or integer values, they must be converted.
Syntax: function RegSetValue(Key: HKey; SubKey: PChar; ValType: Longint; Value: PChar; cb: Longint): Longint;
Key: The Handle of the parent key (can be HKEY_CLASSES_ROOT).
SubKey: The subkey for which the value should be stored.
ValType: must be REG_SZ for win31.
Value: The value to be stored.
cb: Size in bytes for the Value parameter. Windows 3.1 ignores this paramater.
Returns: ERROR_SUCCESS if function was successful; otherwise an error is
returned.
3.4) RegQueryValue()
--------------------
Reads a value from a given key (only PChar). If you want to read a boolean
or integer value, it must be converted since the win31 registry only stores
strings.
Syntax: function RegQueryValue(Key: HKey; SubKey: PChar; Value: PChar; var cb: Longint): Longint;
Key: The Handle of the parent key (can be HKEY_CLASSES_ROOT).
SubKey: The subkey from which the value should be read.
Value: Pointer to a buffer, which stores the read information. Must be a PChar.
cb: Size of the buffer. Contains the number of chars in the buffer, after
completion of the function.
NOTE: The docs say, that the cb parameter is ignored for RegSetValue() and
RegQueryValue(). My experience (Using Delphi and Win95 preview) is the
contrary. Be sure alsways to set the cb parameter to the appropriate
buffer size.
3.4) RegDeleteKey()
-------------------
Delets a key from the registry.
Syntax: function RegDeleteKey(Key: HKey; SubKey: PChar): Longint;
Key: The Handle of the parent key (can be HKEY_CLASSES_ROOT).
SubKey: The subkey which should be deleted.
Returns: ERROR_SUCCESS if the key was deleted, or ERROR_ACCESS_DENIED if
the key is in use by another application.
3.5) RegEnumKey()
-----------------
Enumerates the keys for an open key.
Syntax: function RegEnumKey(Key: HKey; index: Longint; Buffer: PChar; cb: Longint): Longint;
Key: The handle of an open key (can be HKEY_CLASSES_ROOT)
index: The index of the subkey to retrieve. Should be zero on the first call.
Buffer: A buffer which will contain the name of the subkey when the function
returns.
cb: The size of the buffer. Holds the number of chars copied to the buffer
after completion of the function.
Returns: ERROR_SUCCESS if the function was successful. Otherwise an error is
returned.
NOTE: Normally an application starts the enumeration with an index value
of zero and increments it step by step.
GENERAL NOTES: HKEY_CLASSES_ROOT does not need to be opened. It is always
open and avaliable. However, using RegOpenKey() and
RegCloseKey() on the HKEY_CLASSES_ROOT will speed up performance
on subsequent read/write calls.
Hope this helps!
VSF
www.victory.hpg.com.br
www.boatoda.hpg.com.br