Article View: cn.bbs.comp.program
Article #1265ʹ��PowerBuilder����500������(��)
From: ���ܵ�Сʨ
Date: Sat, 18 Apr 1998 00:00
Date: Sat, 18 Apr 1998 00:00
154 lines
9399 bytes
9399 bytes
������ܼ������õ�API����
��������
Windows����ϵͳ�����ļ�����һ��ĵͼ�������÷����൱��
��,����PowerBuilder��Ϊ��ʵ����һЩ�ͼ�����,�������DZ����õ�
�����(��:FUNCky for PowerBuilder��) ����C����֮�������
�����Լ��Ŀ�,���ַ������ǽ��ں�����½������ۡ�������,������
�Ƚ�����ε���WindowsAPI����ʵ�ּ��ֳ��õĵͼ�����:�ļ�
������
ʹ��WindowsAPI���õ���������Ҫ�ô���:���������
Ҫ����Ψһ�ͼ�����,�ڷ���Ӧ��ʱ�Ͳ���Ҫͬʱ������Ŀ����
ȥ���������ʹ�õ�������ṩ���������,Ϊ�����,ʹ��
����������ṩ����̿���Ҫ���Щ��
ʵ��
������������local external����:
Function long LZOpenFile(string FileName, REF ws_ofs
truct FileStructur e, uint style)
Library "lzexpand.dll"
Function long CopyLZFile(uint SourceHandle, uint Des
tHandle) Library"l zexpand.dll"
Function long LZClose (uint FileHandle) Library "lz
expand.dll"
ws_ofstruct�Ĵ��ڼ��ṹ����:
��1
��������Ĵ��ڼ�����:
wf_copy
//����:
boolean
//����:
//string
as_source
//string
as_dest
long
ll_SourceFileHandle, ll_DestFileHandle, ll_result
ws_ofstruct lstr_SourceFileStructure, lstr_DestFileStr
ucture
//��Դ�ļ�
ll_SourceFileHandle = LZOpenFile ( as_source, lstr_Sourc
eFileStructure, 0)
IF ll_SourceFileHandle = -1 THEN
MessageBox ( "�������", "�����ļ�: " + as_source
)
Return FALSE
END IF
//��Ŀ���ļ�
ll_DestFileHandle = LZOpenFile ( as_dest, lstr_DestFileS
tructure, 4096 )
IF ll_DestFileHandle = -1 THEN
MessageBox ( "�������", "�������ļ�: " + as_dest )
LZClose ( ll_SourceFileHandle )
Return FALSE
END IF
//����
ll_result = CopyLZFile ( ll_SourceFileHandle, ll_DestFil
eHandle )
IF li_result < 0 THEN
MessageBox ("�������","�������ļ�: " + as_source
+ " to file: " + as_dest )
LZClose ( ll_SourceFileHandle )
LZClose ( ll_DestFileHandle )
Return FALSE
END IF
//�ر��ļ�
LZClose ( ll_SourceFileHandle )
LZClose ( ll_DestFileHandle )
Return TRUE
����ԭ��
Windows����COMPRESS.EXE��һ����ִ�г���,���ڴ������Le
mpel-ziv�㷨ѹ�����ļ�������Windows�ڲ������˼���������һ
�㷨�ĺ���,����LzCopy�������������ɽ�ѹ���ļ���ͬʱLzCopy
������ĵ��л�������˵��:"���ԭ�ļ�δ��ѹ��,�ú�����ԭ��
����"����LzCopy����Ҳ��������һ�����ٵ��ļ���������
LzCopy��������������:ԭ�ļ���Ŀ���ļ��ľ�����ҵ���,
PowerBuilder�ṩ��F ileOpen����ص��ļ������LzCopy��
��Ҫ���Ǹ�������,������WindowsAPI�е�LzCopy����,���DZ�
��ͬʱʹ��LzOpenFile��LzClose����,��ȷ���������Ҫ���ļ����
��
LzFileOpen��������������һ��������Ҫ���ļ����
����������һ���ṹ, ����ṹ���ں������ʱ�����й�����ļ���
��Ϣ����PowerBuilder��FileOpen����һ��, LzFileOpen������Դ�
�����һ���ļ����ú���ĵ��������ָ���ú����DZ�������ֻ��
��ʽ���ļ�(0),������ֻд��ʽ�����ļ�(4096)��
�����Ǵ���Դ�ļ���Ŀ���ļ���,����ֻҪ�ؽ����ص���
�����ļ��ľ��ݸ�LzCopy����,�Ϳ�ʵ���ļ����������,���˳�
֮ǰ����LzClose�������ر��������ļ���
�ж���һӦ���Ƿ���������
ʵ��
������������local external����
Function uint GetModuleHandle(string ModuleName) Libra
ry "kernel"
Function uint GetModuleUsage(uint ModuleName) Library
"kernel"
Function uint FindExecutable(string FileName, REF str
ing Directory, REF string Result) Library "shell"��������
�Ĵ��ڼ�����:
fw_check_app_status
//����:
boolean
//����:
//
string as_filename
//
string as_directory
integer
li_size = 144, li_result
string
ls_executable = Space ( li_size )
integer
li_module_usage
uint
li_module_handle
li_result = FindExecutable ( as_filename, as_directory,
ls_executable )
IF li_result < 32 THEN Return FALSE
//���ִ���ļ�������,��ȡ���ִ���ļ��ľ��
li_module_handle = GetModuleHandle ( ls_executable )
IF li_module_handle < 1 THEN
//û������
Return FALSE
ELSE
//��ȡ�ж��ٸ�ʵ������
li_module_usage = GetModuleUsage ( li_module_handle )
Return TRUE
END IF
����ԭ��
��γ�����Ի�ȡij��Ӧ���Ƿ��������С�
������WindowsAPI�е�GetModuleHandle�������ж��Ƿ�����һ
��Ӧ���������С�Ϊ��������һ��,������Ҫ֪���ļ���ȫ·����(��
���������·��)�����ǿ��Խ������Ӧ�õ�.INI�ļ���,Ҳ����
ͨ��д��Դ����ķ�������Ƕ���ִ�г������������Ƽ����Dz�
��ǰһ�ַ���,��������ʹӦ�þ��и�������ԡ�������Ĵ��ڼ�
������,�����������û���WindowsĿ¼�в���WIN.INI�ļ�����Ϊ��
�в�ѯ��Ӧ�����ض���չ����ĵ�֮��Ĺ�������¼��WIN.INI�ļ�
�С�����������Ҫ���ĵ�һ���¾�����WIN.INI�ĵ��в�����һ����,
��֪��������ҪѰ�ҵ�Ӧ����ͨ���ĸ����װ��ġ����ǿ����Լ�
����WIN.INI�ļ�,���ߵ���WindowsAPI�е�FindExecutable��������
����һ��Ϣ������,����ʹ���˵ڶ��ַ�����ֻҪ����ϣ��Ѱ�ҵĿ�
ִ�г�����������ļ��������·�����ݸ�FindExecutable����,��
��õ��ÿ�ִ�г����ȫ·����������ʱ��Ҫ�ж�ij��ִ�г�����
��������,���û�о������������������,���Ϸ����Ǻ����õġ�
һ������˿�ִ�г����ȫ·����,���ǽ���ݸ�GetModuleHa
ndle�������Ӧ����������,��ú����Ӧ�õľ������0
,˵��Ӧ�ò�û��װ��,��ʱ�˳��������Ӧ����������,���ǽ���
�õ�Ӧ�õľ��ݸ�GetModuleUsage�����������ķ���ֵ���
���������Ӧ���м�����ͬ��ʵ�������ǵ�������,����ѯ��Ӧ
����Microsoft Word,��Ӧ�ò�������ʵ��ͬʱ����,����NotePad
�����Ӧ��,�ɶ��ʵ��ͬʱ���С���Щ��Ϣ�Ի��Ƿdz����õġ�
--
[m[1;32m�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: hsia.nju.edu.cn][m
Technical Details
Message-ID:
<3O9iV8$tf2@bbs.nju.edu.cn>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB X-Google-Thread: fc86e,e928c918049b0c4c,start X-Google-Attributes: gidfc86e,public From: pipishi.bbs@bbs.nju.edu.cn (���ܵ�Сʨ) Subject: ʹ��PowerBuilder����500������(��) Date: 1998/04/18 Message-ID: <3O9iV8$tf2@bbs.nju.edu.cn> X-Deja-AN: 345408778 X-Filename: Programming/M.892912088.A Organization: nju_bbs Newsgroups: cn.bbs.comp.program