如何判断一个程序是否是dos版本,并替换其图标?(50分)

M

Mary

Unregistered / Unconfirmed
GUEST, unregistred user!
如何判断一个exe程序是win95版本还是以前的Dos版本。

如果是Dos版本,怎样替换其图标?

谢谢!
 
好象是读Exe文件头,具体内容记不得了,Dos程序同Windows程序通过此信息来区分。

或者是读字符串“This program require microsoft windows”,不知道可不可
以。
 
呵呵, 目前, 所有的Win3.x/Win95/NT的应用程序
都可以说也是一个Dos程序, 因为他们都有一个Dos
可执行文件头(MZ), 但是, 他们的Dos可执行部分(术语
叫做Stub)通常仅仅打印一条信息“This program
require microsoft windows”外什么事也不做.
除了MZ头之外, 这些程序还有NE或者PE文件头,
Dos的Exec功能只认MZ头的入口, Win31/95则优先
考虑NE头的入口, NT更能够识别PE头, 根据PE头的
信息载入程序

判断“This program require microsoft windows”字符串不能
保证可靠性,

DOS可执行程序没有图标资源, 必须用PIF文件, 或者lnk文件
来设置图标
 
谢谢两们朋友,另:
请教pegasus:
怎样取得mz、NE、PE头?
怎样用PIF文件或lnk文件来设置图标?
不好意思,小女子才疏学浅,能不能请你详细点?万分感激。

附:我想做到与win95建立桌面快捷方式一样,知道是dos程序
(但可以在win95下运行),马上弹出对话框让用户选择一个图标。
我的目的是让管理员能自定义桌面(只有用户自已要使用的程序,
没有象网上领居,我的电脑等)。
如:仓库保管人员用的电脑只能运行仓库程序及管理员允许其使用
的程序(如Word),保证计算机安全(不会乱删文件)及效率
(不干与工作无关的事)。
 
这应该用Policy Editer实现,改图标的办法也没什么用.
 
嗨, 使用Win95, 就不可能这么安全, 即使用了Poly来限制,
也很容易被绕过.
关于文件头, 我现在手头一时查不到, 您可以找一下
金山公司出的&lt&lt深入Windows编程 &gt&gt
 
什么是Policy Editer和poly,能否指点我查哪本资料,最好是能在网上下载。
也许win95下怎么防止也是不安全,但总比什么防止都没有要好,是吧。
再向各位请教,我怎样才能完成我的任务?救命!
 
Win95的光盘里就有,Admin目录里poledit
 
将文件头读进来,判断否否Exe
offset(0) -$5a45 'MZ'
offset($80) = 'PE' WIN32 EXE
offset($100) = 'NE' WIN16 EXE

e_magic:SmallInt
buffer:array[0..255] of byte;
FStream:TFileStream;

FStream:=TFileStream.Create(Filename,fmOpenRead+fmShareDenyNone);
Try
FStream.Read(buffer,256);
if SmallInt(buffer[0]) <>$5A4D then
FIsMSDos:=False
else
FIsMSDos:=True;

nPos:=$80

if (buffer[nPos+0]='P') and (buffer[nPos+1]='E') and (buffer[nPos+2]=#0) and (buffer[nPos+3]=#0) then
FIsPE:=True;

finally
FStream.Free;

nPos:=$100
if (buffer[nPos+0]='N') and (buffer[nPos+1]='E') then
FIsNE:=True;
 
我在jiangtao的程序上做了一点改动,请教jiangtao不知把buffer定义为
bytet和char有何区别,哪个更好些?
procedure TForm1.Button1Click(Sender: TObject);
var
buffer:array[0..255] of char;
FStream:TFileStream;
npos:integer;
begin
FStream:=TFileStream.Create('c:/arj/append.exe',fmOpenRead+fmShareDenyNone);
Try
FStream.Read(buffer,256);
nPos:=$80 ;
if (buffer[nPos+0]='P') and (buffer[nPos+1]='E') and (buffer[nPos+2]=#0) and (buffer[nPos+3]=#0) then
showmessage('32位exe程序')
else
begin
nPos:=$100 ;
if (buffer[nPos+0]='N') and (buffer[nPos+1]='E') then
showmessage('16')
else
showmessage('dos程序')
end;
finally
FStream.Free;
end;
end;


另外,我用poledit编辑了一个 .pol文件,但不知怎么使用。(用poledit
直接修改注册表能马上起到效果。)

谢谢大家!^_^
 
为95用的.pol文件必须放在域服务器的netlogon目录下
这是一个网络共享,实际目录是NT/system32/.....下的
一个目录。

文件名称必须叫做Config.pol,才能为95使用。
95必须登录到域上,而且要用Poledit指明从
服务器上读取配置参数。
 
Hi Mary,

Windows 根本就无安全可言, policy editor 只能更改一些个性化设置。不少公司
都做了一些安全程序,结果都不尽人意,只能隐藏一些东西如控制面板、驱动器...
 
>>金山公司出的<<深入Windows编程 >
Hehe, JiangTao大侠曾经是金山公司的项目负责人的呦!
 
Hi Sister Mary,

Here is the original messag from a shareware called "Folder Guard" I just got (I am going to mail it to you anyway):

Folder Guard is a software-only security solution for personal or
publicly accessible computers running the Windows 95 operating
system. Its features include:

o Complete control over access to folders of your choice. You can
hide or make actually "read-only" any folder, so that access to
its contents will be restricted to all applications including
Explorer, MS Office, MS-DOS programs, common dialogs, etc.

o Optional user validation at logon, which helps protect your
Windows 95 files from intruders. You can choose to disable the
Cancel button on the logon prompt or set up a password to logon as
"default" user. A log file can be set up to help you keep track
of the use of your computer.

o Password access to protected folders that can be set up, or
changed, at any time.

o Flexible control of user access to many Windows 95 resources, such
as the Start Menu, Control Panel, etc.

o User-specific access rights to folders and to other Windows 95
resources that you can configure separately for each user of your
computer.

o Easy and intuitive user interface that helps you set up the
attributes of folders you want to protect, and helps you control
other settings, as well.

o Protection that's transparent to both users and applications.
While protecting specified folders and other resources, Folder
Guard uses only about 30K of RAM.

o Designed to operate with or without the use of System Policies, on
a stand-alone computer or on a network.
 
谢谢各位大侠,大家对我的帮助很大(几乎要眼泪鼻涕一起下了),
我会通知版主分配积分的。

————Mary
 
Wa, 我一分都没有, 好伤心呦!
Wuwu, Mary, 下次我不参与您的问题了! :)
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
346
import
I
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部