怎么可能?就好像让没脑子的人记事情一样。
无外乎三种办法:
1)注册表
2)程序本身
3)ini文件

解决方案 »

  1.   

    可以写到自身的exe中,可是有必要弄得那么复杂吗?
      

  2.   

    看过一些介绍,可以的。
    首先要有两个程序,main和config,运行config,配置你的CONNECTSTRING,写入main(在main中用预留给CONNECTSTRING空间,或者在指定地方先放一些空格填充)。
    在main运行的时候再读出这个CONNECTSTRING就可以了,不过实现好像比较复杂。
      

  3.   

    to ALL:
      多谢大家的关心!
    to qiubolecn、cszhz:
      我的程序是已经编译好EXE文件,有没有可能在程序中预留一些空间,由其他程序写入?具体怎么做,能不能给点详细的说明,或是应用的例子,我好入手
      

  4.   

    如你讲的,还是在尾部添加的好!
    但为什么非要只用一个文件呢!
    创建一个ini其实很有效吗?也不必这么大费周折!
      

  5.   

    如果需要加入的数据太大,EXE文件的空间不够装呢
      

  6.   

    但是我在程序中如何读呢?
    var
       t:textfile;
       s:string;
    begin
       assignfile(t,'project2.exe');
       reset(t);
       while not eof(t) do
       begin
         readln(t,s);
         showmessage(s);
       end;
       closefile(t);
    end;
    好象读不出我写进去的内容喔!
      

  7.   

    因为我做的程序是中间层的应用服务器,调用者只有调用这个应用服务器的权限,所以不能借助其他的资源,例如INI文件
      

  8.   

    用INI文件装配置,在EXE文件中用变量读取这些设置不就成了吗?
    这不就很简单。
      

  9.   

    INI,注册表很简单,如果加到自身文件后就麻烦
      

  10.   

    多谢大家!经过实验,发现写在EXE文件的最后是可行的,但是如何读出来就是问题了,我写的代码如下,但得不到预期的结果,希望大家能出点主义:
    procedure TForm1.Button1Click(Sender: TObject);
    var
       t:TFileStream;
       s:string;
       c:array [0..65535] of char;
       f:textfile;
    begin
       assignfile(f,'project2.exe');
       append(f);
       writeln(f,'abcdefg=asb');
       closefile(f);
       try
          t:=tFileStream.Create('project2.exe',fmOpenRead);
          showmessage(‘filesize:'+inttostr(t.size));
          t.Read(c,t.size+1);
          s:=c;
          showmessage(inttostr(pos('abcdefg=asb',s)));
       finally
          t.free;
       end;
    end;
      

  11.   

    用BlockWrite,BlockRead等读写
    t.Read(c,t.size+1);有问题,最好添加部分长度是固定的,这样整个文件长度减去固定长度就是你添加数据的开始处
      

  12.   

    既然只有运行权限,肯定写运行程序本身也是不可以的。答案很绝:不可能在本机实现!除了一个例外:借助外力:在程序里面固定设置一个Config Server(也可以通过广播获取,UDP/NetBIOS etc.),连接上就可以通过远程通信读写配置了。
      

  13.   

    在大富翁里找到的答案,可我在WIN2000运行总出错,给大家试试,有结果不要忘了告诉我一声
    program Hello;{$APPTYPE CONSOLE}uses
      Windows, SysUtils;
    var                                               //
      szSrc,                                          //
      szDest    : array[0..MAX_PATH] of char;         //
      szCmdLine : string;
      hFile     : THandle;
      hProcess  : THandle;
      SI        : TStartupInfo;
      PI        : TProcessInformation;
      nTimes    : DWord;
    begin
    if ParamCount = 0 then
       begin
       GetModuleFileName(0, szSrc, MAX_PATH);
       GetTempPath(MAX_PATH, szDest);
       GetTempFileName(szDest, 'Tmp', 0, szDest);
       CopyFile(szSrc, szDest, FALSE);                 // 将当前可执行文件复制一个副本   hFile := CreateFile(szDest,                     // pointer to name of the file
                           0,                          // access (read-write) mode
                           FILE_SHARE_READ,            // share mode
                           nil,                        // pointer to security attributes
                           OPEN_EXISTING,              // how to create
                           FILE_FLAG_DELETE_ON_CLOSE,  // file attributes
                           0);                         // handle to file with attributes to copy   hProcess := OpenProcess(SYNCHRONIZE,            // access flag
                               TRUE,                   // handle inheritance flag
                               GetCurrentProcessId);   // process identifier
       szCmdLine := Format('%s %d "%s"', [szDest, hProcess, szSrc]); //格式化命令行参数   FillChar(SI, SizeOf(SI), 0);
       SI.cb := SizeOf(SI);   CreateProcess(nil,                              // pointer to name of executable module
                     PChar(szCmdLine),                 // pointer to command line string
                     nil,                              // pointer to process security attributes
                     nil,                              // pointer to thread security attributes
                     TRUE,                             // handle inheritance flag
                     0,                                // creation flags
                     nil,                              // pointer to new environment block
                     nil,                              // pointer to current directory name
                     SI,                               // pointer to STARTUPINFO
                     PI);                              // pointer to PROCESS_INFORMATION   CloseHandle(hProcess);
       CloseHandle(hFile);
       end
    else
       begin
       hProcess := THANDLE(StrToInt(ParamStr(1)));
       WaitForSingleObject(hProcess, INFINITE);        //等待主进程结束
       CloseHandle(hProcess);   hFile := FileOpen(ParamStr(2), fmOpenReadWrite);
       if hFile > 0 then
          begin
          FileSeek(hFile, $80, 0);
          FileRead(hFile, nTimes, SizeOf(nTimes));
          Inc(nTimes);
          FileSeek(hFile, $80, 0);
          FileWrite(hFile, nTimes, SizeOf(nTimes));
          FileClose(hFile);
          Writeln('我已经运行'+IntToStr(nTimes)+'次了');
          end;
       end;
    end.