注:这里在IE添加按钮的方式跟Flashget、Windows Messenger等程序类似,即通过注册表添加。

解决方案 »

  1.   

    该不是和IE的设置有关吧,IE保护本机资源。
    看看可不可以通过设置IE解决,将安全级别降到最低高手切磋,全当参考吧
      

  2.   

    不会吧?IE的按纽也只是ShellExecute你的程序而已,应该没什么启动方式不同啊
      

  3.   

    to 513(513) :
    我把安全级别设置为最低还是不行。to cnhgj(戏子):
    你的意思是不是直接打开和通过IE按钮打开是一样的?
    但是,我这边确实不一样。
      

  4.   

    Exec的值就是应用程序的路径:
    E:\Documents and Settings\qiuji\My Documents\Visual Studio Projects\myapp1\bin\Debug\myapp1.exe
      

  5.   

    我刚才测试了一下,调用了我以前用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
      

  6.   

    我把访问.ini文件的代码重新写了一下,没有引用原来的那个dll文件。
    直接运行,没有问题,能够取到.ini中的值,但是,在IE中用按钮打开依然不行。
      

  7.   

    补充一下:
    读写.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);
      

  8.   

    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
      

  9.   

    谢谢saucer(思归) !
    我把所有的选项全部设置为“完全信任”,还是跟原来一样。另外,我的程序与服务器无关,完全是在本地运行,而且该程序跟一般的程序一样,并且不需要网络的支持。
      

  10.   

    会不会是.net的原因?忆秋季,你试试用别的开发工具写一个试试
      

  11.   

    谢谢cnhgj(戏子)!
    就算其他的开发工具可以,但是.net下不能实现也不行啊,我想一定是有原因的。
      

  12.   

    do you have try/catch in your code, show the error messages when you call GetPrivateProfileString/WritePrivateProfileString
      

  13.   

    谢谢思归!
    我终于发现错误了,
    我以前用:
    ini=new Form2("inifile\\test.ini");
    直接运行,没有问题,在IE中打开就不行。现在换成:
    ini=new Form2(Application.StartupPath+"\\inifile\\test.ini");
    两者都可以了。不过,为什么第一个方法有问题?
    难道通过IE点击的应用程序运行的时候,还与IE保持一定的关系?
      

  14.   

    恭喜恭喜~~!^_^,我的delphi也是通过绝对路径访问的ExtractFilePath(Application.ExeName)+'xxx.ini'
      

  15.   

    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)
      

  16.   

    原来,通过IE打开后CurrentDirectory

    E:\Documents and Settings\qiuji\My Documents\Visual Studio Projects\myApp1\bin\Debug
    变成了:
    E:\Documents and Settings\qiuji\桌面非常感谢各位的回答!特别要感谢思归!
    现在结贴!