<font color=red>关于OCX中读取文件的问题</font>(100分)

  • 主题发起人 ZhangFei
  • 开始时间
Z

ZhangFei

Unregistered / Unconfirmed
GUEST, unregistred user!
我自已写了一只OCX,出现以下不解,请高手指教:

1,OCX中要读取一个文件(而且比较大,有5M多),放在服务器上。
OCX在用户端(浏览器中)执行后,如何指定文件的路径?

2,Java Applet不能写前端的硬盘,OCX有无此类限制?
 
C

CJ

Unregistered / Unconfirmed
GUEST, unregistred user!
1、直接指定文件不幸吗 ?
2、无
 
Z

ZhangFei

Unregistered / Unconfirmed
GUEST, unregistred user!
我的意思是,如果在程序中指定

<font color=red>MyObject.OpenFile('1.dat');</font>

此类的语句,那么在前端不就等于映射到了客户机上的硬盘了吗?
我的要求是要读取服务器端的数据。
 
A

Another_eYes

Unregistered / Unconfirmed
GUEST, unregistred user!
用完整路径试试.
//servername/path/filename
 
C

chenke

Unregistered / Unconfirmed
GUEST, unregistred user!
反正都要下载到客户端:
1。直接把文件包到ocx中。
或:
2.在客户端用Socket传输这个文件,再装载。
 
H

huizhang

Unregistered / Unconfirmed
GUEST, unregistred user!
你的OCX是否准备在浏览器上运行?
 
H

huizhang

Unregistered / Unconfirmed
GUEST, unregistred user!
一个办法是给这个(这一类)文件定义一个特殊的扩展名, 在客户端将此扩展名绑定到
某一个Exe程序, 该EXE文件能够自动判断出这个扩展名并且调用你的OCX来打开这个
文件. 如此设之后, 就可以通过Internet在客户端打开该文件了.

这个办法就是著名的Whip的做法, 他将DWF(AutoCAD Drawing Internet Extention)
绑定到IE浏览器上通过Whip.OCX来显示它.

不过5M的文件远程访问有点困难, 但是局域网,企业网上还能对付. 但是不论怎样最
理想的还是应该简化该文件. 例如AutoCAD的Drawing文件都是很大的, 特此搞出了
一个DWF格式(DWG的1/10)以适应网上浏览的需要.
 
L

lhz

Unregistered / Unconfirmed
GUEST, unregistred user!
按我的理解,ActiveX和JavaApplet是有很大不同的:

JavaApplet是Server在客户机上运行的一部分,可以看作是Server端软件,
所以Applet有方便访问Server端文件的接口.但由于用户对Server的不信任,
Applet将不能访问Client端的文件(新的标准好象允许用户设置Applet的权限).

ActiveX是Client端的一部分,与Server基本无关,ActiveX的安装必须完全通过
用户的信任,所以,ActiveX控件代表的是Client,而不是Server.所以,ActiveX
可以访问Client端的文件,但要访问Server端的文件,必须显式调用通信接口.而
且还要通过Server的安全检查.
 
Z

ZhangFei

Unregistered / Unconfirmed
GUEST, unregistred user!
多人接受答案了。
 
H

huizhang

Unregistered / Unconfirmed
GUEST, unregistred user!
这个问题还没搞定就放弃了, 请下载:

http://support.microsoft.com/download/support/mslfiles/Mimetype.exe

这是微软的InPlacePlayer的一个例子(C++), 示范了如何做一个MIME(Multimedia
Internet Mail Extension)ActiveX播放远程媒体文件.

下面是MSDN的一段话:
Downloading the File
Internet Explorer does not download the file before sending the URL
to the player. The player is responsible for retrieving the file and
playing it. There are a number of ways to handle this depending on
what the player needs to do. One way is illustrated in the sample
with the URLDownloadToCacheFile function. This function downloads the
file only if necessary and returns the name of the local cached copy
of the file. It should be noted that URLDownloadToCacheFile is a
blocking function. Even though the data is downloaded asynchronously
the function does not return until all the data is downloaded.

If complete asynchronous downloading is desired, one of the other UOS functions, such as URLOpenStream, or perhaps general URL monikers would be more appropriate. The following code is taken from CMimetypeCtrl::DoPropExchange (in Mtpctl.cpp) and fills up the string m_cstrCacheFileName with the complete path of the local file:

if ( FAILED(URLDownloadToCacheFile(
GetControllingUnknown(), // control's IUnknown
m_cstrFileName, // URL to download
m_cstrCacheFileName.GetBuffer(MAX_PATH),// buffer to fill with name
MAX_PATH, // buffer length
0, // reserved
NULL )) ) // no status information
{
AfxMessageBox("Cannot download file");
m_cstrCacheFileName = "Not Found";
return;
}
 
J

James

Unregistered / Unconfirmed
GUEST, unregistred user!
通常先Down到Cache,再打开。如果不用Cache,就用Stream了.
我曾作了个东东----Netscape的Plugins,可以直接Access Server的
File, 或Cache的File.
 

Similar threads

顶部