달력

42024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

 lib 목록


 - Tled, Tindicator, logmeter,scope....




Posted by theF
|

Component 메뉴 - Install Package - Add


델파이 bin 폴더 안에 dclqrt70.bpl 을 선택



끝.

Posted by theF
|

Component -> Install Packages


델파이 7 설치 폴더에 bin


dclSockets70.bpl -> add 



끝  .



Posted by theF
|

var

 

    aHandle : THandle;

    PID : Integer;

 

aHandel := FindWindow ('TfrmMain',nil);                      //첫번째 인자는 클래스명(델파이 제작프로그램)

 

aHandel := FindWindow('NotePad',nil);                          //메모장등은 프로그램명만 

또는

aHandel := FindWindow(nil,'제목 없음 - 메모장');            //캡션만

또는

aHandel := FindWindow('NotePad','제목 없음 - 메모장'); //둘다 알때

Posted by theF
|
procedure TForm1.Button1Click(Sender: TObject);
var
  time1,time2,ptime, msecday : TTimeStamp;
  //msecday1 : Double;
  itmp1, tmp1,tmp2,tmp3, tmp4,tmp5,tmp6,tmp7 : integer;
begin
 //msecday1 := (1/(24*60*60));
  time1 := DateTimeToTimeStamp(StrToDateTime('2000-02-02 02:50:00'));
  time2 := DateTimeToTimeStamp(StrToDateTime('2000-02-03 05:51:20'));

  ptime.Time := time2.Time - time1.Time;
  ptime.Date := time2.Date - time1.Date;

  if ptime.Time < 0 then begin
    Dec(ptime.Date);
    ptime.Time := MSecsPerDay + ptime.Time;
  end;

  edit2.Text := IntToStr(ptime.date * MSecsPerDay + ptime.Time);

  itmp1 := StrToInt(edit2.Text);  //msec

  itmp1 := Trunc(itmp1/1000);


  tmp1 := itmp1 div 86400; //day

  tmp2 := itmp1 mod 86400;

  tmp3 := tmp2 div 3600;  //HH

  tmp4 := tmp2 mod 3600;

  tmp5 := tmp4 div 60;  //NN

  tmp6 := tmp4 mod 60;   //ss

  edit3.Text := IntToStr(tmp1)+'일'+IntToStr(tmp3)+'시간'+IntToStr(tmp5)+'분'+ IntToStr(tmp6)+'초';



end;


두 날짜 뺀후 결과 msec 출력.


해당 msec를 날짜 시간 분 초로 구분...

원문1 : http://newworlds.tistory.com/618

원문2 : http://bloodguy.tistory.com/entry/PHP-%EC%8B%9C%EA%B0%84%EC%9D%84-%EC%B4%88%EB%A1%9C-%ED%99%98%EC%82%B0-%EC%B4%88%EB%A5%BC-%EC%8B%9C%EA%B0%84%EC%9C%BC%EB%A1%9C-%ED%99%98%EC%82%B0



Posted by theF
|

..

function MyExitWindows(RebootParam: Longword): Boolean;
var
  TTokenHd: THandle;
  TTokenPvg: TTokenPrivileges;
  cbtpPrevious: DWORD;
  rTTokenPvg: TTokenPrivileges;
  pcbtpPreviousRequired: DWORD;
  tpResult: Boolean;
const
  SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
begin
  if Win32Platform = VER_PLATFORM_WIN32_NT then
  begin
    tpResult := OpenProcessToken(GetCurrentProcess(),
      TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
      TTokenHd);
    if tpResult then
    begin
      tpResult := LookupPrivilegeValue(nil,
                                       SE_SHUTDOWN_NAME,
                                       TTokenPvg.Privileges[0].Luid);
      TTokenPvg.PrivilegeCount := 1;
      TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
      cbtpPrevious := SizeOf(rTTokenPvg);
      pcbtpPreviousRequired := 0;
      if tpResult then
        Windows.AdjustTokenPrivileges(TTokenHd,
                                      False,
                                      TTokenPvg,
                                      cbtpPrevious,
                                      rTTokenPvg,
                                      pcbtpPreviousRequired);
    end;
  end;
  Result := ExitWindowsEx(RebootParam, 0);
end;

// Example to shutdown Windows:

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyExitWindows(EWX_POWEROFF or EWX_FORCE);
end;

// Example to reboot Windows:

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyExitWindows(EWX_REBOOT or EWX_FORCE);
end;


// Parameters for MyExitWindows()

출처 : 한국 델파이 개발자 동호회

http://www.delphi.co.kr/?document_srl=157263&act=trackback&key=d5f

Posted by theF
|

델마당 오익환님이 2003년경에 너그럽게 올려주신 자료를 꼬불쳐 옴.

소스는 없고, dcu만 있으며, 본인은 아직 테스트 해보지 못함.
그러나, demo로 봐서는 따른 그리드 알아볼 필요는 없을듯..

고맙습니다. 익환님...델마당~ 

 
Posted by theF
|

re] 비트통신법을 알려주세요...ㅡ..ㅡ 
 

안녕하셔요...

음..통신이 시리얼(rs232) 이죠..

그렇다면 비트 또는 니블 통신이라는 것도 결국 바이트 통신과 같습니다.

다만 바이트는 상대편이 한 바이트를 가지고 하나의 정보를 가지는것이고

비트는 한바이트를 가지고 8개의 각각 다른 정보를 가지는것이고

니블은 한바이트를 가지고 2개의 각각 다른 정보를 가지는 것이랍니다.

그럼..예를 들어 볼까요...

1. 비트 통신

비트는 주로 DI,DO등의 접점에 많이 쓰이죠..

한바이트 가지고 8개의 DI,DO를 제어할수 있어닌깐 통신량이 그만큼 줄어들겠죠..

예를 들어 8개의 램프가 있고 이걸 켜고 싶다면(비트로 매핑되어 있을 경우)

실제 데이터는 한바이트만 쓰여지죠..

const 
  BitFieldOn : array[1..8] of Byte = ($01,$02,$04,$08,$10,$20,$40,$80); 
  BitFieldOff : array[1..8] of Byte = ($FE,$FD,$FB,$F7,$EF,$DF,$BF,$7F);

var 
  senddata : Byte;

  senddata := 0; //데이터 초기화

  //1번,7번을 켜고 싶을 경우 
  senddata = senddata or BitFieldOn[1]; 
  senddata = senddata or BitFieldOn[7];

  //전송 
  comport.writechar(senddata);

  //7번을 끄고 싶을 경우 
  senddata = senddata and BitFieldOff[7]; 
  //전송 
  comport.writechar(senddata);

또는 귀찮어시면 다음 함수를 사용하셔도 됩니당.

// 주어진 바이트에서 원하는 비트를 끄잡어 내기.. 
function GetBitFromByte(B : Byte; Count: Integer) : Boolean; 
begin 
  Case Count of 
    0: Result := Boolean((B and $80) shr 7); 
    1: Result := Boolean((B and $40) shr 6); 
    2: Result := Boolean((B and $20) shr 5); 
    3: Result := Boolean((B and $10) shr 4); 
    4: Result := Boolean((B and $08) shr 3); 
    5: Result := Boolean((B and $04) shr 2); 
    6: Result := Boolean((B and $02) shr 1); 
    7: Result := Boolean(B and $01); 
  else 
    Result := True; 
  end; 
end;

// 주어진 바이트에 원하는 비트를 셋팅하기.. 
procedure SetBitToByte(var B : Byte; Count: Integer; Value: Boolean); 
begin 
  Case Count of 
    0: if Value then B := B or $80 else B := B and $7F; 
    1: if Value then B := B or $40 else B := B and $BF; 
    2: if Value then B := B or $20 else B := B and $DF; 
    3: if Value then B := B or $10 else B := B and $EF; 
    4: if Value then B := B or $08 else B := B and $F7; 
    5: if Value then B := B or $04 else B := B and $FB; 
    6: if Value then B := B or $02 else B := B and $FD; 
    7: if Value then B := B or $01 else B := B and $FE; 
  end; 
end;

2. 니블 통신

니블은 주로 카운터를 표시할때 많이 쓰이죠..

예를 들어 자동차 키로수처럼 카운터 메터를 표시할경우 한바이트로 두개의 영역을

표시할수 있어닌깐 이또한 통신 데이터를 줄일수 있겠죠..

예를 들어 9999를 표시한다면 두바이트면 되겠죠..

var 
  aa,bb : Byte; 
begin 
  aa := 0; 
  bb := 0;

  //1234를 전송할 경우 
  aa := ($01 shl 4) or $02; 
  bb := ($03 shl 4) or $04;

  comport.writechar(aa); 
  comport.writechar(bb); 
end;

휴~ 이상 입니당.

그럼..즐거운 주말 되시구요..항상 건강하셔요..

>장비가 10년전거라그러는데요, 지금도 사용잘하고 있답니다. 
>그당시 플을 업그레이드 하면서 제가 델로 하니까 델로 업을 하려는데요 
>비트통신이 되야되거든요... 
>이중에서도 두가지 입니다. 한종류는 비트통신 또하나는 4bit를 한 값으로 
>이용하는 니블통신이요. 
>이자 겨우 바이트 통신을 알게 된지 얼마 안되었는데 
>비트 통신을 하게 되었답니다.. 
>단, 4비트의(니블값) 최고값이 9를 넘지는 않더군요...즉 0 에서 9까지만여 

>지금 고민중이긴 한데 될듯될듯 안되네요...ㅜ..ㅜ 

>예제나 샘플이나 know-where등등 많이 많이 알려주시와요... 
>언릉 끝내야 하거든요.... 

>감사합니다.... 

Posted by theF
|

소트 알고리즘.

기술자료 2009. 12. 8. 17:38

몇가지 소트 알고리즘

procedure BubbleSort(Items: TStrings);
var
done: boolean;
i, n: integer;
Dummy: string;
begin
n := Items.Count;

repeat
done := true;
for i := 0 to n - 2 do
if Items[i] > Items[i + 1] then
begin
Dummy := Items[i];
Items[i] := Items[i + 1];
Items[i + 1] := Dummy;

done := false;
end;
until done;
end;


procedure SelectionSort(Items: TStrings);
var
i, n, maxIndex, topIndex: integer;
Dummy: string;
begin
n := Items.Count;

for topIndex := n - 1 downto 1 do
begin
maxIndex := topIndex;
for i := 0 to topIndex - 1 do
if Items[i] > Items[maxIndex] then
maxIndex := i;

Dummy := Items[topIndex];
Items[topIndex] := Items[maxIndex];
Items[maxIndex] := Dummy;
end;
end;


procedure InsertionSort(Items: TStrings);
var
i, Position, n: integer;
Value: string;
Done : boolean;
begin
n := Items.Count;

for i := 1 to n - 1 do
begin
Value := Items[i];
Position := i;
Done := false;

while not done do
begin
if Position <= 0 then
Done := true
else
if Value >= Items[Position - 1] then
Done := true
else
begin
Items[Position] := Items[Position - 1];
Position := Position - 1;
end;
end;

Items[Position] := Value;
end;
end;
Posted by theF
|