为什么?
Delphi中很多“解决不了”的问题只要使用Build with Runtime Packages
就可以解决?
难道不这样子就不行?——怪不得Delphi的版本兼容性巨差!用呀用呀,用到D7才发现:
在Delphi帮助里:
String to PChar conversionsDelphi6中:
Long string to PChar conversions are not automatic. Some of the differences between strings and PChars can make conversions problematic:Long strings are reference-counted, while PChars are not.
Assigning to a string copies the data, while a PChar is a pointer to memory.
Long strings are null-terminated and also contain the length of the string, while PChars are simply null-terminated.Situations in which these differences can cause subtle errors are discussed in this section.Delphi7中:
Long string to PChar conversions are not automatic. Some of the differences between strings and PChars can make conversions problematic:Long strings are reference-counted, while PChars are not.
Assigning to a string copies the data, while a PChar is a pointer to memory.
Long strings are null-terminated and also contain the length of the string, while PChars are simply null-terminated.Situations in which these differences can cause subtle errors are discussed in the following topics:String dependencies 
Returning a PChar local variable 
Passing a local variable as a PChar 多了三个连接:
String dependencies 
Returning a PChar local variable 
Passing a local variable as a PChar 
其中 Returning a PChar local variable 写道:
A common error when working with PChars is to store a local variable in a data structure, or return it as a value. When your routine ends, the PChar disappears because it is a pointer to memory, and not a reference counted copy of the string. For example:function title(n: Integer): PChar;
var
  s: string;
begin
  s := Format('title - %d', [n]);
  Result := PChar(s); // DON'T DO THIS
end;This example returns a pointer to string data that is freed when the title function returns.DON'T DO THIS!!!Delphi不让这么做啦~!?!在帮助 Passing a local variable as a PChar 中讲道:
Consider the case where you have a local string variable that you need to initialize by calling a function that takes a PChar. One approach is to create a local array of char and pass it to the function, then assign that variable to the string:// assume FillBuffer is a predefined function
function FillBuffer(Buf:PChar;Count:Integer):Integer
begin
  . . .
end;
// assume MAX_SIZE is a predefined constant
var
  i: Integer;
  buf: array[0..MAX_SIZE] of char;
  S: string;
begin
  i := FillBuffer(0, buf, SizeOf(buf)); // treats buf as a PChar
  S := buf;
  //statements
end;This approach is useful if the size of the buffer is relatively small, since it is allocated on the stack. It is also safe, since the conversion between an array of char and a string is automatic. The Length of the string is automatically set to the right value after assigning buf to the string.To eliminate the overhead of copying the buffer, you can cast the string to a PChar (if you are certain that the routine does not need the PChar to remain in memory). However, synchronizing the length of the string does not happen automatically, as it does when you assign an array of char to a string. You should reset the string Length so that it reflects the actual width of the string. If you are using a function that returns the number of bytes copied, you can do this safely with one line of code:var
  S: string;
begin
  SetLength(S, MAX_SIZE; // when casting to a PChar, be sure the string is not empty
  SetLength(S, GetModuleFilename( 0, PChar(S), Length(S) ) );
  // statements
end;我考~ 
真烦~
郁闷~仔细一看,其实在Delphi6的Help中就有这个了,就是没在“主页”做连接!惨呀~伤心了~!
难道真的逼我......

解决方案 »

  1.   

    在teamB的建议,或者在以前的帖子里都有阿,只是你没有注意而已,应该不会怪borland,还有想datetime的类型,方法指针,重载等等,help里写的非常详细,我觉得help能写到这个分上,非常不错了,只是大家没有注意看而已,不客气的说,论坛上至少1/4的帖子能在help中找到答案!
      

  2.   

    最起码Delphi的跨平台还是挺牛的
      

  3.   

    我也觉得Delphi跨平台时问题多多,也许是我水平太菜了
      

  4.   

    delphi开发应用至少还是快的,什么语言要深入都需要花时间
      

  5.   

    ?????????
    string to PChar
    就直接  PChar(str);
    PChar to string
    就直接
    str := StrPas(ch);
    就可以了啊
      

  6.   

    如果一个学了一门语言花了1年,结果没有学到什么,发现了很多Bug,觉得不好,然后学过一门语言,过了1年后产生了同样的想法。那你2年等于花了1年学了一门语言。
    如果你能克服这些,致力于你的专业,你的技术,你等于2年学了1门语言,水平自然不用说了。
      

  7.   

    支持delphi,因为他的伟大。但是delphi的语法不一致性太多了。学习起来太麻烦。不如c++的语法好学(c++的语法一致性非常好)
      

  8.   

    每天按一下F1。
    对自己帮助不少啊。
    进步也很大的。
    我先是按F1找不到答案就到GOOGLE。
    再找不到就到CSDN收索贴子。
    再找不到就发贴请教咯!