奇怪!程序启动方式不同,运行也不同?请思归等高手进来看看!200分!

qiuji 2003-10-22 06:02:28
我写了一个程序,直接运行可以正常运行。
现在,我在IE的工具栏中添加了一个按钮,该按钮可以打开该程序。
可是,通过该按钮打开程序后,程序可以运行,但是有一个dll文件没有加载。
该dll文件是我自己写的,用来读写.ini文件。
也就是说,现在通过IE上的按钮启动程序,读.ini文件的功能没有了。
不知是什么原因?
难道直接打开和通过IE工具栏按钮打开有什么不同之处?
请大家赐教!谢谢!
...全文
53 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
qiuji 2003-10-22
  • 打赏
  • 举报
回复
原来,通过IE打开后CurrentDirectory

E:\Documents and Settings\qiuji\My Documents\Visual Studio Projects\myApp1\bin\Debug
变成了:
E:\Documents and Settings\qiuji\桌面

非常感谢各位的回答!特别要感谢思归!
现在结贴!
saucer 2003-10-22
  • 打赏
  • 举报
回复
in the first method, the default current directory is Application.StartupPath, but in IE, it has its own default current directory, somewhere in
"C:\Documents and Settings\YourLogin"?

try
MessageBox.Show(System.Environment.CurrentDirectory)
cnhgj 2003-10-22
  • 打赏
  • 举报
回复
恭喜恭喜~~!^_^,我的delphi也是通过绝对路径访问的ExtractFilePath(Application.ExeName)+'xxx.ini'
qiuji 2003-10-22
  • 打赏
  • 举报
回复
谢谢思归!
我终于发现错误了,
我以前用:
ini=new Form2("inifile\\test.ini");
直接运行,没有问题,在IE中打开就不行。

现在换成:
ini=new Form2(Application.StartupPath+"\\inifile\\test.ini");
两者都可以了。

不过,为什么第一个方法有问题?
难道通过IE点击的应用程序运行的时候,还与IE保持一定的关系?
saucer 2003-10-22
  • 打赏
  • 举报
回复
do you have try/catch in your code, show the error messages when you call GetPrivateProfileString/WritePrivateProfileString
qiuji 2003-10-22
  • 打赏
  • 举报
回复
谢谢cnhgj(戏子)!
就算其他的开发工具可以,但是.net下不能实现也不行啊,我想一定是有原因的。
cnhgj 2003-10-22
  • 打赏
  • 举报
回复
会不会是.net的原因?忆秋季,你试试用别的开发工具写一个试试
qiuji 2003-10-22
  • 打赏
  • 举报
回复
谢谢saucer(思归) !
我把所有的选项全部设置为“完全信任”,还是跟原来一样。

另外,我的程序与服务器无关,完全是在本地运行,而且该程序跟一般的程序一样,并且不需要网络的支持。
saucer 2003-10-22
  • 打赏
  • 举报
回复
so everything is local or downloaded from the server?

go to Control Panel->Administrative Tools->.NET Framework 1.1 Configuration, right click on Runtime Security Policy, try to add or adjust security, give permissions to run Unmanaged code
qiuji 2003-10-22
  • 打赏
  • 举报
回复
补充一下:
读写.ini文件,我使用了,
[DllImport("kernel32")]

private static extern long WritePrivateProfileString(string section,

string key,string val,string filePath);

[DllImport("kernel32")]

private static extern int GetPrivateProfileString(string section,

string key,string def, StringBuilder retVal,

int size,string filePath);
qiuji 2003-10-22
  • 打赏
  • 举报
回复
我把访问.ini文件的代码重新写了一下,没有引用原来的那个dll文件。
直接运行,没有问题,能够取到.ini中的值,但是,在IE中用按钮打开依然不行。
musclecn 2003-10-22
  • 打赏
  • 举报
回复
两棵星的问题,我是看都没有必要看的。
up!!
cnhgj 2003-10-22
  • 打赏
  • 举报
回复
我刚才测试了一下,调用了我以前用delphi写的程序,程序中有访问ini文件,很正常

BUTTONTEXT =dd
CLSID = {1FBA04EE-3024-11D2-8F1F-0000F87ABD16}
DEFAULT VISIBLE = YES
EXEC = G:\myprogram\test.exe
HOTICON = G:\icon\Funny\mr e-mail.ico
ICON = G:\icon\Funny\look no hands.ico
qiuji 2003-10-22
  • 打赏
  • 举报
回复
Exec的值就是应用程序的路径:
E:\Documents and Settings\qiuji\My Documents\Visual Studio Projects\myapp1\bin\Debug\myapp1.exe
cnhgj 2003-10-22
  • 打赏
  • 举报
回复
你的Exec怎么写的?
qiuji 2003-10-22
  • 打赏
  • 举报
回复
to 513(513) :
我把安全级别设置为最低还是不行。

to cnhgj(戏子):
你的意思是不是直接打开和通过IE按钮打开是一样的?
但是,我这边确实不一样。
cnhgj 2003-10-22
  • 打赏
  • 举报
回复
不会吧?IE的按纽也只是ShellExecute你的程序而已,应该没什么启动方式不同啊
513 2003-10-22
  • 打赏
  • 举报
回复
该不是和IE的设置有关吧,IE保护本机资源。
看看可不可以通过设置IE解决,将安全级别降到最低

高手切磋,全当参考吧
haoliqi 2003-10-22
  • 打赏
  • 举报
回复
学习!
jerry051 2003-10-22
  • 打赏
  • 举报
回复
notice!
加载更多回复(2)

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧