中国程序员联盟 正在重新改版中ing 不便之处还请见谅 改版后将内容涉及java delphi .net php
 
  首页 | 数据库开发 | 网络通讯 | 多线程 | 多媒体开发 | 图像处理 | 程序人生 | 系统函数 | 控件开发 | Web服务
 
  当前位置:笨鱼delphi技术网>系统函数>文章内容

delphi 如何写二进制文件到注册表

来源:国外 关于:William Gerbert 发布时间:2007-07-03   [收藏] [推荐]
Problem/Question/Abstract:
Can someone explain exactly how to use WriteBinaryData? I've tried several different ways but the output is never what it should be.
Answer:
uses
  Registry
var
  RG: Registry;
  PrinterName: string; {This is just a value}
  Buffer: array[0..1024] of Char; {This is the Binary data}
  J, K: Integer;
  dFiles: array[0..5] of string;
    {The string data that will be converted to Binary Data}
  S, S2: string;
  sChar: Char;
procedure Whatever;
begin
  {Reset buffer}
  for i := 0 to 1024 do
    buffer[i] := #00;
  {Reset S}
  S := '';
  dfiles[0]: 'MyPrint.Drv';
  dfiles[1]: 'MyPrint.DLL';
  dfiles[2]: 'Myunit.DLL';
  dfiles[3]: 'MyPrint.HLP';
  dfiles[4]: 'MyPrnt2.DLL';
  dfiles[5]: 'MyPrnt3.DLL';
  {Copy all items into one string seperated by a NULL ##00}
  for J := 0 to 5 do
  begin
    S := S + dFiles[k] + #00; {Copy strings to 1 string and add a #00}
    K := Length(S); {K function is to store the string length}
  end;
  {Convert String to char array called buffer}
  for J := 1 to K do
  begin
    S2 := Copy(S, J, 1); {Copy 1 char to string S2}
    sChar := S2[1]; {Copy S2 to sChar}
    buffer[J - 1] := sChar; {Copy sChar to buffer}
  end;
  {The char array MUST end with 2 NULLS}
  Buffer[K + 1] := #00;
  Printername := 'MyPrinter';
  rg := TRegistry.create;
  rg.rootkey := hkey_local_machine;
  rg.Openkey('System\CurrentControlSet\Control\Print\Environments\Windows4.0\Drivers\'
    + PrinterName, true);
  rg.writebinarydata('Dependent Files', buffer, K + 1);
  rg.Closekey;
end;

[浏览: 次]   
上一篇:delphi 表单接收拖动的文件   下一篇:delphi 访问注册表
[收藏] [推荐] [返回顶部] [打印本页] [关闭窗口]  
    评论加载中…
google adsense热点文章
·delphi Delphi中ShellExecute的妙用
·delphi 如何快速读取文本文件
·delphi 如何判断输入值是否中文
·delphi 在应用层截获键盘消息
·delphi delphi实现服务开启与关闭
·delphi 实时记录事件日志
·delphi 使MEMO自动滚动
·delphi 如何区分键盘两个Enter键
·delphi 切换界面的方法
·delphi 汉字输入法的编程及使用
·delphi Delphi程序输入法自动切换最简
·delphi 消息是由谁来发出又由谁来完成
     delphi技术网 | firefox 下载 | Avant Browser下载 | dedecms 技术网 | drupal 爱好者 | php 技术网
  Copyright@www.delphichm.com,2006-2009.All Rights Reserved.
 
程序员联盟 | delphi Java .net|QQ:707102932