Some simple problem! Each problem 50$(50$*3)(150分)

  • 主题发起人 主题发起人 blsm
  • 开始时间 开始时间
B

blsm

Unregistered / Unconfirmed
GUEST, unregistred user!
No1: (50$)
我在做一个数据库软件,其中要求右击数据表的每一列能弹出不同的菜单;
其中,数据表自然使用DBGrid,现在就是要求右击DBGrid的每一列可以弹出不同的PopMenu.


No2: (50$)
简而言之就是控制光驱的弹出和收回;
我察过一些资料,可以用一下代码实现;
uses MMSystem;

......

procedure TForm1.EjeptButtonClick(Sender: TObject);
begin
//To open the CD-ROM
mciSendString('Set cdaudio door open wait', nil, 0, handle);
end;

procedure TForm1.CloseButtonClick(Sender: TObject);
begin
//To close the CD-ROM
mciSendString('Set cdaudio door closed wait', nil, 0, handle);
end;

我试了一下,以上代码可以控制第一个光驱的开闭;
问题是我如何控制所有光取的开闭(光驱数未知,起始盘符未知)
还有mciSendString函数各个参数的用法及意义

No3: (the Simplest 我很懒,不愿去查了,同样50$)
设置文件属性的API函数名称及用法

 
No.3

SetFileAttributes('文件名',属性)
属性为
FILE_ATTRIBUTE_READONLY
FILE_ATTRIBUTE_SYSTEM
FILE_ATTRIBUTE_HIDDEN
等,可以用+号加起来
 
Pipi
那么,我如何设置文件的属性为Not Readonly或Not system,Not Hidden呢
 
>Pipi 也真是的,写东西不写完,让分给我赞了,
现贴一个问题,怕被别人抢了……
NO3。
The SetFileAttributes function sets a file's attributes.
BOOL SetFileAttributes(
LPCTSTR lpFileName, // address of filename
DWORD dwFileAttributes // address of attributes to set
);
Parameters

lpFileName

Points to a string that specifies the name of the file whose attributes are to be set.
Windows 95: This string must not exceed MAX_PATH characters.
Windows NT: There is a default string size limit for paths of MAX_PATH characters. This limit is related to how the SetFileAttributes function parses paths. An application can transcend this limit and send in paths longer than MAX_PATH characters by calling the wide (W) version of SetFileAttributes and prepending "//?/" to the path. The "//?/" tells the function to turn off path parsing; it lets paths longer than MAX_PATH be used with SetFileAttributesW. This also works with UNC names. The "//?/" is ignored as part of the path. For example, "//?/C:/myworld/private" is seen as "C:/myworld/private", and "//?/UNC/bill_g_1/hotstuff/coolapps" is seen as "//bill_g_1/hotstuff/coolapps".

dwFileAttributes

Specifies the file attributes to set for the file. This parameter can be a combination of the following values. However, all other values override FILE_ATTRIBUTE_NORMAL.

Value Meaning
FILE_ATTRIBUTE_ARCHIVE The file is an archive file. Applications use this value to mark files for backup or removal.
FILE_ATTRIBUTE_NORMAL The file has no other attributes set. This value is valid only if used alone.
FILE_ATTRIBUTE_HIDDEN The file is hidden. It is not included in an ordinary directory listing.
FILE_ATTRIBUTE_READONLY The file is read-only. Applications can read the file but cannot write to it or delete it.
FILE_ATTRIBUTE_SYSTEM The file is part of the operating system or is used exclusively by it.
FILE_ATTRIBUTE_TEMPORARY The file is being used for temporary storage. File systems attempt to keep all of the data in memory for quicker access rather than flushing the data back to mass storage. A temporary file should be deleted by the application as soon as it is no longer needed.
Windows 95 only: FILE_ATTRIBUTE_ATOMIC_WRITE Reserved for future use; do not specify.
Windows 95 only: FILE_ATTRIBUTE_XACTION_WRITE Reserved for future use; do not specify.
Return Value

If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error information, call GetLastError.

 
1:
将Options得dgMuiltSelect:=False;
判断DBGrid1.SelectedIndex得不同弹出不同得PopMenu
 
2:
当要知道所选的驱动器属于什么类型时,请看下面的程序

var x:integer;

driver:pchar;

begin

driver:='f:/';

x := GetDriveType(driver);

Case x of

2: Label1.Caption := '该驱动器是可移动驱动器';

3: Label1.Caption := '该驱动器是固定驱动器';

4: Label1.Caption := '该驱动器是网络驱动器';

5: Label1.Caption := '该驱动器是CD-ROM驱动器';

6: Label1.Caption := '该驱动器是虚拟驱动器';

Else Label1.Caption := '该驱动器无效';

End;

end;
 
多人接受答案了。
 
后退
顶部