home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-10-17 | 1.6 KB | 75 lines | [TEXT/CWIE] |
- unit MyDesktopDB;
-
- interface
-
- uses
- Files;
-
- function GetDesktopDB (vrn: integer; var rn: integer): OSErr;
- { You can safely ignore the error and use the returned rn in calls to Get/Set, they will just bounce }
- procedure GetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
- procedure SetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
-
- implementation
-
- uses
- GestaltEqu,
- MyTypes;
-
- function GetDesktopDB (vrn: integer; var rn: integer): OSErr;
- var
- pb: DTPBRec;
- oe: OSErr;
- v: longint;
- begin
- rn := bad_rn;
- oe := Gestalt(gestaltDBAccessMgrAttr, v);
- if (oe = noErr) & not BTST(v, gestaltDBAccessMgrPresent) then begin
- oe := -1;
- end;
- if oe = noErr then begin
- pb.ioNamePtr := nil;
- pb.ioVRefNum := vrn;
- oe := PBDTGetPath(@pb);
- if oe = noErr then begin
- rn := pb.ioDTRefNum;
- end;
- end;
- GetDesktopDB := oe;
- end;
-
- procedure GetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
- var
- pb: DTPBRec;
- oe: OSErr;
- begin
- s := '';
- if rn <> bad_rn then begin
- pb.ioNamePtr := @fs.name;
- pb.ioDTRefNum := rn;
- pb.ioDTBuffer := @s[1];
- pb.ioDirID := fs.parID;
- oe := PBDTGetCommentSync(@pb);
- if oe = noErr then begin
- s[0] := chr(pb.ioDTActCount);
- end else
- s := '';
- end;
- end;
-
- procedure SetDTDBComment (rn: integer; var fs: FSSpec; var s: Str255);
- var
- pb: DTPBRec;
- oe: OSErr;
- begin
- if rn <> bad_rn then begin
- pb.ioNamePtr := @fs.name;
- pb.ioDTRefNum := rn;
- pb.ioDTBuffer := @s[1];
- pb.ioDTReqCount := length(s);
- pb.ioDirID := fs.parID;
- oe := PBDTSetCommentSync(@pb);
- end;
- end;
-
- end.