我想利用比较底层的方法,比如写ini文件或者注册表谢谢!

解决方案 »

  1.   

    http://www.csdn.net/Develop/read_article.asp?id=25607
      

  2.   

    delphi里面哪有二楼说的那些函数的声明阿?
      

  3.   

    procedure TForm1.BitBtn2Click(Sender: TObject);
    begin
      try
      Ta:=TRegistry.Create;
      Tb:=TRegistry.Create;
      Ta.RootKey:=HKEY_LOCAL_MACHINE;
      if not Ta.OpenKey('software\odbc\odbc.ini\'+edit2.text+'\',true) then
        begin
          ta.OpenKey('software\odbc\odbc.ini\',true);
          ta.CreateKey(edit2.text);
        end;
       ta.WriteString('database',edit2.text);
       ta.WriteString('driver','c:\winnt\system32\sqlsrv32.dll');
       ta.WriteString('lastuser','sa');
       ta.writestring('server','(local)');
       ta.WriteString('Trusted_Connection','yes');
       //The second key for driver a odbc
       Tb.RootKey:=Ta.RootKey;
       Tb.OpenKey('software\odbc\odbc.ini\odbc data sources\',true);
       tb.WriteString(edit2.text,'SQL SERVER');
      except
        showmessage('error');
      end;
     { if not Ta.ValueExists(edit1.text) then /////////
        begin
          Ta.CreateKey(edit1.text);
        end;     }
    end;这是我做过的一个例子,你看看吧
      

  4.   

    谢谢楼上的回答,但是我很想知道:SQLCreateDataSource
    SQLConfigDataSource. 
    SQLManageDataSources 
    SQLConfigDataSource 在哪里找?delphi哪个头文件里面有?
      

  5.   

    我很想知道:SQLCreateDataSource
    SQLConfigDataSource. 
    SQLManageDataSources 
    SQLConfigDataSource 在哪里找?delphi哪个头文件里面有?
      

  6.   

    楼主,不好意思,我尝试了一下,这样可以用!!function SQLConfigDataSource(hwndParent: Integer; fRequest: Integer;lpszDriverString: String; lpszAttributes: String): Integer;stdcall;external 'ODBCCP32.DLL';      //函数定义部分//函数调用实例
    SQLConfigDataSource(0, ODBC_ADD_SYS_DSN,'SQL Server',     //ODBC_ADD_SYS_DSN是常量
                          'DSN='+ DSN + chr(0) +              //需要定义为4
                          'Server='+ Server + chr(0) +
                          'Database='+ DBName + chr(0) +
                          'Description=ODBC Source'+ chr(0));