Windows

A: Vladimir Ilynkin. ? ??: 15.08.2004

??B? ?? C++ Builder




HG??? ??p?? ? FAQ ???? ???? ???Sp?
FidoNet "RU.CBUILDER".

pIy DG? y pA C? ??pppAy
?? C? ? ??? ??G? yB.

*p: ? ? ?? ??B ??? DJ??? C?, ???
???? ??Hp?.


LK y??Q? ???? y?? ??B?:

1 ? y, ? ??? ? D
??????? IE ? ??? ? D? ?? ??? py?
2 ??B? ??? pp?
3 ??p? AnsiString ??AppA? ? char?
4 ??p? AnsiString ??AppA? ? int?
5 ??p? AnsiString ??AppA? ? float?
6 ??p? char ??AppA? ? AnsiString?
7 ??p ? ??H ? ??G? ? p??
8 "????? ??" AnsiString? @y ??? @?
AnsiString ?? ??y ??J? "-=" ? "=-".
9 pC? ? DOS-Z?? ? (??pA?? pZ?)?
10 yA? pp ??Gp? ??p ? 1024x768 ?
11 AnsiString ??pA? ? ??pAy (OEM)?
12 ??? @p? ? yy?? ? ? ? ? ??
13 ??? p ??Bp?? yA? @? ?? ?? ??p???
14 ??Gp? MIDI ? MediaPlayer-??
15 Hy ? RichEdit ??? Cp ? *.rtf ?? ? ?? ??? ?
??? ??Bp??, ?.?. ??? ?????? ?? ? y. ?
???? ??? @p? p??p Cp?? ??
16 ? @ p?? Alt+F4 D ppA??
17 ?, @? ??? G? ??H ?????Q ListBox'?, y ??pB?
? ?? ? ?? ListBox ??????? Hint?
18 ? @ p?? D ppA? ?: Alt+F4, Alt+Tab,
Ctrl+Break, Ctrl+Alt+Del?
19 ? ??FpM? IM ? p??? ? ??@I, ??D????
20 y? p? ?? ??
21 @pK ??? Cp? ? ? p?? pIy D?
22 ? Internet ? ??IpM ??
23 ?, @? ?? ? OnExit, ? D??p Edit-A, ??p?
y??? LB? ?? A? M??
24 y? pp?? Windows-? ?
25 pIy ? RichEdit, @? ??? ?? ypp B??? ?
??U? ?- pI??
26 C? yI? ? y??G? A ? ??p.
27 pA? ?? p??(??Bp??) ?
28 p? DOC y??Q Word-K.
29 ? FullScreen?
30 y? ? ? ListView?
31 ??Ap?, ?? ?? ?? ????? ??Bp???
32 D ??J? ?????? ??? y? ????? ??Bp???
33 pp ??? COM ??p.
34 ??Bp??? ??? ??Gp?
35 ??? ????? G y ?
36 ??? ? ??By, ??py? D???? y ? ?? ? ??? -
? Ctrl+Alt+Del, ??p?? D ppy ? ?? Alt+F4,
Ctrl+Break, ?.?.?. ?
37 p? p? ?????? ? 2 p? ? ????
38 ?????? RasEnumConnections?
39 ???? ? ??Bp?? ??, ???? ?? pC? G????? G? ?? D
@p???, ?? ? EM? ??? p?
? pC?. ??? ? ??
40 ??Bp??? ??py py ? RichEdit, ? py???
? ??? ??? ??? ? ??? PageDown?
41 ??? ??Bp??? Windows?
42 ? y ?? ??Bp???
43 BDE ? DBF D??pp? C@p??? ???? py??? ???, ? ???
44 pC? ? ????? p COM ??p? (????/??? L)?
45 ??? ??? @p? -?? ? Internet'K ? D??
46 y? ???? ???? ?? ??? ??Bp???




1 > ? y, ? ??? ? D ??????? IE ? ??? ? D?
>?? ??? py?

p?? TLabel, ? p? y D? - G?, ??p??y?,
ypp Cy?? ?. CK ??@ OnClick:
void __fastcall TForm1::Label1Click(TObject *Sender)
{
ShellExecute(Handle, "open", "http://chto-to.gde-to.com",
0, 0, SW_SHOW);
}

Alexey Panin (2:5030/1045.30)



2 > ??B? ??? pp?

SendMessage(Application->Handle,WM_SYSCOMMAND,SC_SCREENSAVE,0);

Andrej Kalinicenko 2:5020/400



3 > ??p? AnsiString ??AppA? ? char?

AnsiString ? ="Egor Letov";
char b = a.c_str();




4 > ??p? AnsiString ??AppA? ? int ?

B@?:
1. int i = HH.ToInt();
2. int i = StrToInt(HH);

Victor Moroz 2:5020/175.2



5 > ??p? AnsiString ??AppA? ? float ?

AnsiString s = ("12.5"); // F? ??p? "s" ?? AnsiString
float d; // F? ??p? "d" ?? float

d=s.ToDouble(); // p? ??pM? "d" ??pM? "s"

Ruslan Mogilevsky 2:468/22.40



6 > ??p? char ??AppA? ? AnsiString?

char Arr[240];
AnsiString StrTemp;

StrTemp=(AnsiString)Arr;

A?? 2:5020/175.2



7 > ??p ? ??H ? ??G? ?
7 > p??

SS>>IntToHex

Hpp, ?:
int i=217;
AnsiString s=IntToHex(i,6);//from SySsUtils
ShowMessage(s);//0000D9
i=StrToInt("0x"+s);
ShowMessage(IntToStr(i));//217




7 > ??p ? ??H ? ??G? ?
7 > p??

int IntN = 1024, digits = 8;
AnsiString HexN = IntToHex(IntN, digits);




8 > "????? ??" AnsiString? @y ??? @?
> AnsiString ?? ??y ??J? "-=" ? "=-".

AnsiString Name="Egor";
Name="-="+Name+"=-";
Label1->Caption=Name;




9 > pC? ? DOS-Z?? ? (??pA?? pZ?)?

p!
C ??? p:

#define CYR_WIN 1251
#define CYR_ISO88595 28595
#define CYR_DOS866 866
#define CYR_DOS855 855
#define CYR_MAC 10007
#define CYR_KOI8R 20866
#define CYR_KOI8U 21866
#define CYR_MACU 10017

typedef HRESULT (__stdcall
*TConvertFunction)(LPDWORD,DWORD,DWORD,LPCSTR,LPINT,LPBYTE,LPINT );

class TConvert
{
private:
HINSTANCE dll;
TConvertFunction ConvertFunction;
public:
TConvert()
{
dll=NULL;
dll=LoadLibrary("mlang.dll");
if(!dll)
throw Exception("Can't load mlang.dll!");
ConvertFunction=(TConvertFunction)
GetProcAddress(dll,"ConvertINetString");
if(!ConvertFunction)
{
if(dll!=NULL)
FreeLibrary(dll);
dll=NULL;
throw Exception("Can't load function ConvertINetString");
}
}
~TConvert()
{
if(dll!=NULL)
FreeLibrary(dll);
dll=NULL;
}
bool ConvertString(int src_cp,int dest_cp,const AnsiString Src,AnsiString
&Dest)
{
bool ReturnValue;
Dest="";
int sizeSrc=Src.Length()+1;
char *buf=new char[sizeSrc+1];
int sizedest=sizeSrc+1;

ReturnValue=ConvertFunction(0,src_cp,dest_cp,
Src.c_str(),&sizeSrc,
buf,&sizedest)==S_OK;
if(ReturnValue) Dest=buf;
delete []buf;
return ReturnValue;
}
};
//---------------------------
J??A:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TConvert C;
AnsiString KOI8R;
if(C.ConvertString(CYR_WIN,CYR_KOI8R,Memo1->Text,KOI8R))
{
FILE *fp=fopen("c:\\koi8.txt","w");
fputs( KOI8R.c_str(),fp);
fclose(fp);
}
}
//-----------------


C? ??? yA??LH ??p? ???-p@ ???? ? IE.

Andrej Kalinicenko

=================================================

9 > pC? ? DOS-Z?? ? (??pA?? pZ?)?


static char * convert_cyr_string(unsigned char *str, int length, char from,
char to);

typedef unsigned char _cyr_charset_table[512];

const static _cyr_charset_table _cyr_win1251 = {
0,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,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,
46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,
154,174,190,46,159,189,46,46,179,191,180,157,46,46,156,183,
46,46,182,166,173,46,46,158,163,152,164,155,46,46,46,167,
225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
0,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,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,184,186,32,179,191,32,32,32,32,32,180,162,32,
32,32,32,168,170,32,178,175,32,32,32,32,32,165,161,169,
254,224,225,246,228,229,244,227,245,232,233,234,235,236,237,238,
239,255,240,241,242,243,230,226,252,251,231,248,253,249,247,250,
222,192,193,214,196,197,212,195,213,200,201,202,203,204,205,206,
207,223,208,209,210,211,198,194,220,219,199,216,221,217,215,218,
},
_cyr_cp866 = {
0,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,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
35,35,35,124,124,124,124,43,43,124,124,43,43,43,43,43,
43,45,45,124,45,43,124,124,43,43,45,45,124,45,43,45,
45,45,45,43,43,43,43,43,43,43,43,35,35,124,124,35,
210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
179,163,180,164,183,167,190,174,32,149,158,32,152,159,148,154,
0,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,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
205,186,213,241,243,201,32,245,187,212,211,200,190,32,247,198,
199,204,181,240,242,185,32,244,203,207,208,202,216,32,246,32,
238,160,161,230,164,165,228,163,229,168,169,170,171,172,173,174,
175,239,224,225,226,227,166,162,236,235,167,232,237,233,231,234,
158,128,129,150,132,133,148,131,149,136,137,138,139,140,141,142,
143,159,144,145,146,147,134,130,156,155,135,152,157,153,151,154,
},
_cyr_iso88595 = {
0,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,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,179,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,209,
32,163,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
0,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,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,241,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,161,32,32,32,32,32,32,32,32,32,32,32,32,
238,208,209,230,212,213,228,211,229,216,217,218,219,220,221,222,
223,239,224,225,226,227,214,210,236,235,215,232,237,233,231,234,
206,176,177,198,180,181,196,179,197,184,185,186,187,188,189,190,
191,207,192,193,194,195,182,178,204,203,183,200,205,201,199,202,
},
_cyr_mac = {
0,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,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
225,226,247,231,228,229,246,250,233,234,235,236,237,238,239,240,
242,243,244,245,230,232,227,254,251,253,255,249,248,252,224,241,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,179,163,209,
193,194,215,199,196,197,214,218,201,202,203,204,205,206,207,208,
210,211,212,213,198,200,195,222,219,221,223,217,216,220,192,255,
0,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,31,
32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
160,161,162,222,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,221,180,181,182,183,184,185,186,187,188,189,190,191,
254,224,225,246,228,229,244,227,245,232,233,234,235,236,237,238,
239,223,240,241,242,243,230,226,252,251,231,248,253,249,247,250,
158,128,129,150,132,133,148,131,149,136,137,138,139,140,141,142,
143,159,144,145,146,147,134,130,156,155,135,152,157,153,151,154,
};

/***************************************************************************
**
* k - koi8-r
* w - windows-1251
* i - iso8859-5
* a - x-cp866
* d - x-cp866
* m - x-mac-cyrillic
****************************************************************************
*/
static char * convert_cyr_string(unsigned char *str, int length, char from,
char to)
{
const unsigned char *from_table, *to_table;
unsigned char tmp;
int i;

from_table = NULL;
to_table = NULL;

switch (toupper(from))
{
case 'W':
from_table = _cyr_win1251;
break;
case 'A':
case 'D':
from_table = _cyr_cp866;
break;
case 'I':
from_table = _cyr_iso88595;
break;
case 'M':
from_table = _cyr_mac;
break;
case 'K':
break;

}

switch (toupper(to))
{
case 'W':
to_table = _cyr_win1251;
break;
case 'A':
case 'D':
to_table = _cyr_cp866;
break;
case 'I':
to_table = _cyr_iso88595;
break;
case 'M':
to_table = _cyr_mac;
break;
case 'K':
break;


}


if (!str)
return (char *)str;

for( i = 0; i {
tmp = (from_table == NULL)? str[i] : from_table[ str[i] ];
str[i] = (to_table == NULL) ? tmp : to_table[tmp + 256];
}
return (char *)str;
}

Valeriy Filchenkov (2:5045/78.78)



10 > yA? pp ??Gp? ??p ? 1024x768 ?

HDC hDCScreen = GetDC(NULL);
int horres=GetDeviceCaps(hDCScreen,HORZRES);
int vertres=GetDeviceCaps(hDCScreen,VERTRES);
int freq=GetDeviceCaps(hDCScreen,VREFRESH);
ReleaseDC(NULL, hDCScreen);
horres=1024;
vertres=768;
DEVMODE dm;
ZeroMemory(&dm, sizeof(DEVMODE));
dm.dmSize = sizeof(DEVMODE);
dm.dmPelsWidth = horres;
dm.dmPelsHeight = vertres;
dm.dmDisplayFrequency = freq;
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
ChangeDisplaySettings(&dm, 0);

Starikov Alexander (2:5020/400)



11 > AnsiString ??pA? ? ??pAy (OEM)?

. yI.
BOOL CharToOem(
LPCTSTR lpszSrc, // pointer to string to translate
LPSTR l
pszDst // pointer to translated string
);

? p???? 2:5020/175.2



12 > ??? @p? ? yy?? ? ? ? ? ??

GetLogicalDrives
GetLogicalDriveStrings

? @p?? ??:

GetDriveType

Dmitry Belov (2:5020/400)



13 > ??? p ??Bp?? yA? @? ?? ?? ??p???

ActivateKeyboardLayout(LoadKeyboardLayout(IntToHex(MAKELANGID(LANG_RUSSIAN,
SUBLANG_DEFAULT),8).c_str(),0),0);

Sergei Andreev 2:5020/400



14 > ??Gp? MIDI ? MediaPlayer-??

C????
#include

??K ?:
HWND MCIHwnd;

=== py? Windows Clipboard ===
void __fastcall TFMain::PlayMIDI()
{
if (MCIHwnd) return;
if (bNoMusic) return;
......................
//Play MIDI:
MCIHwnd = MCIWndCreate(Application->Handle, HInstance, NULL, "el.mid");
MCIWndPlay(MCIHwnd);
}
=== ?? ===

=== py? Windows Clipboard ===
void __fastcall TFMain::FormClose(TObject *Sender, TCloseAction &Action)
{
//Destroy MIDI:
if (MCIHwnd) MCIWndDestroy(MCIHwnd); MCIHwnd = NULL;
}
=== ?? ===
Evgeniy Buyvis 2:5036/10.53



14 > ??Gp? MIDI ? MediaPlayer-??

#include

mciSendString("open anny.mid type sequencer alias MUSIC", NULL, 0, 0);
mciSendString("play MUSIC from 0", NULL, 0, 0);

Valeriy Filchenkov 2:5045/78.78



15 >Hy ? RichEdit ??? Cp ? *.rtf ?? ? ?? ??? ?

??? ??Bp??, ?.?. ??? ?????? ?? ? y. ?
????

Form1->Caption = String("My Application - ") + OpenDlg->FileName;

> ??? @p? p??p Cp?? ??

int h = FileOpen(OpenDlg->FileName, fmOpenRead);
int sz = FileSeek(h, 0, 2); // p??p ?
FileClose(h);
RichEdit1->LoadFromFile(OpenDlg->FileName);

Alexey Panin 2:5030/1045.30



16 > ? @ p?? AltF4 D ppA??

@pC?? FormKeyDown ??:

if(Shift.Contains(ssAlt)&&Key==VK_F4)Tag=1;

@pC?? FormCloseQuery:

if(Tag)
{
CanClose=false;
Tag=0;
}

Mihail Kotelnikov 2:5054/18.60



17 > ?, @? ??? G? ??H ?????Q ListBox'?, y
17 > ??pB?
> ? ?? ? ?? ListBox ??????? Hint?

Gy ????G? p?? :

Application->HintPause = 0;
Application->HintShortPause = 0;
Application->HintHidePause = 10000000000;
Application->OnShowHint = TIn4Form->DoShowHint;


void __fastcall TIn4Form::DoShowHint(System::AnsiString &HintStr, bool
&CanShow, THintInfo &HintInfo)
{
CanShow = true;
if (HintInfo.HintControl == ListBox3 )
{
if( Mouse->Capture )
{
CanShow = false;
return;
}
HintInfo.ReshowTimeout = 100;
/*HintInfo.HintColor = clAqua;// Changes only for this hint*/

TPoint pnt;
SIZE strsize;
int numstr = ListBox3->ItemAtPos(HintInfo.CursorPos,true);
if(numstr<0)
{
CanShow = false;
Application->HideHint ();
return;
}
HintStr = ListBox3->Items->Strings[numstr];
strsize = ListBox3->Canvas->TextExtent(HintStr);
if(strsize.cx<=ListBox3->ClientWidth)
{
CanShow = false;
Application->HideHint ();
return;
}
pnt.x = -1;
pnt.y =
int(HintInfo.CursorPos.y/ListBox3->ItemHeight)*ListBox3->ItemHeight - 3;
pnt = ListBox3->ClientToScreen(pnt);
HintInfo.HintPos.x = pnt.x;
HintInfo.HintPos.y = pnt.y;
HintInfo.HintMaxWidth = Screen->Width-pnt.x;
/*HintInfo.HideTimeout = 100;*/
}
}


D y ??? ShowHint y py? ListBox-?.

Denis Dudko 2:5020/400



18 > ? @ p?? D ppA? ?: Alt+F4, Alt+Tab,
> Ctrl+Break, Ctrl+Alt+Del?

// ======================== ? WIN98/WINME ==========================
??? ?:
1 - ? p?? /StayOnTop/
2 - Background p??
/Windowstate=wsMaximized/BorderStyle=bsNone/BorerIcons - ? ?
false/FormStyle=fsNormal/??p? CanDelete ? y????G? p? ?
OnCloseQuery

p? ? ???? p pp? ? pH J p?
p??? ? ??? - ? Ipy Alt-Tab, Ctrl-Alt-Del
Alt-F4 - Ipy? ? OnCloseQuery

// yp? ??Bp?? ?? ? - pppy ??? ??G?
void __fastcall TFMainForm::FormCreate(TObject *Sender)
{
// p? ??G? ??D?? ? Windows
typedef int (__stdcall *RegisterServiceProcess) (int , int);
HANDLE hkernel32;
RegisterServiceProcess rgProcess;
hkernel32 = GetModuleHandle("kernel32.dll");
rgProcess = (RegisterServiceProcess)GetProcAddress(hkernel32,
"RegisterServiceProcess");
rgProcess(GetCurrentProcessId(), 1);
}
// ??Ap?? ??p p?
void __fastcall TFMainForm::FormCloseQuery(TObject *Sender, bool &CanClose)
{
// pAp?? ??pJ? ??p ?
TFPass *pass = new TFPass(this);
pass->PassText = "";
if (pass->ShowModal() == mrOk)
if (pass->PassText == "my password")
CanClose = true;
else
{
MessageDlg("password error", mtError, TMsgDlgButtons() << mbOK,
0);
CanClose = false;
}
else
CanClose = false;
}

// ? ??G? p? :
void __fastcall TFMainForm::EnableAccess()
{
// ?? ????pC p??
if (Form6)
{
Form6->CanDelete = false;
delete Form6;
Form6 = NULL;
}
// ??? p ?????? pp?
SystemParametersInfo (SPI_SCREENSAVERRUNNING,0,&OLDSysPrm,0);
}
// ? ???G? p? :
void __fastcall TFMainForm::DisableAccess()
{
// p pp?
SystemParametersInfo (SPI_SCREENSAVERRUNNING,1,&OLDSysPrm,0);

// Background form
if (!Form6)
{
Form6 = new TForm6(Application);
Form6->CanDelete = false;
Form6->Show();
}
}

p? p?U 2:5020/400



19 > ? ??FpM? IM ? p??? ? ??@I, ??D????

void __fastcall TForm6::Photo()
{
int X0,Y0; bool Flag;
TRect ScreenRect;
TCanvas* ScreenCanvas=new TCanvas;
try
{
Top=0;
Left=Screen->Width;
Width=Screen->Width;
Height=Screen->Height;
ScreenRect=Rect(0,0,Width,Height);
ScreenCanvas->Handle=GetDC(0);
Image1->Canvas->CopyRect(ScreenRect, ScreenCanvas,ScreenRect);
ReleaseDC(Handle,ScreenCanvas->Handle);
Left=Top;

} __finally
{
delete ScreenCanvas;
}
}

p? p?U 2:5020/400



20 > y? p? ?? ??

??p?
FileTimeToLocalFileTime
FileTimeToSystemTime

Andrej Kalinicenko 2:5020/400



20 > y? p? ?? ??

J??A? @?, ? ???? p? ?? py.
C ??p?:

TDateTime FileTimeToDateTime(FILETIME *lpftime)
{
FILETIME localfiletime;
SYSTEMTIME systime;
FileTimeToLocalFileTime(lpftime,&localfiletime);
FileTimeToSystemTime(&localfiletime,&systime);
return (TDateTime(systime.wYear,systime.wMonth,systime.wDay)+

TDateTime(systime.wHour,systime.wMinute,systime.wSecond,systime.wMillisecond
s));
}
//------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
FILETIME ftCreationTime,ftLastAccessTime,ftLastWriteTime;

HANDLE hFile=(HANDLE)FileOpen("c:\\autoexec.bat",fmOpenRead);

GetFileTime(hFile,&ftCreationTime,&ftLastAccessTime,&ftLastWriteTime);

AnsiString FileInfo="FileName: c:\\autoexec.bat";
FileInfo+="\nCreation Time:
"+FormatDateTime("c",FileTimeToDateTime(&ftCreationTime));
FileInfo+="\nLast Access Time:
"+FormatDateTime("c",FileTimeToDateTime(&ftLastAccessTime));
FileInfo+="\nLast Write Time:
"+FormatDateTime("c",FileTimeToDateTime(&ftLastWriteTime));

Label1->Caption=FileInfo;

FileClose((int) hFile);
}

Andrej Kalinicenko 2:5020/400



21 > @pK ??? Cp? ? ? p?? pIy D?

Hpp, ?:
AnsiString __fastcall LoadStringFromFile(AnsiString FileName, int StringNo)
{
AnsiString Result;
TStringList* Strings=new TStringList;
try
{
Strings->LoadFromFile(FileName);
Result=Strings->Strings[StringNo];
}catch(...){}
delete Strings;
return Result;
}

Sergei Andreev 2:5020/400
=========================================================================


22 > ? Internet ? ??IpM ??

ppM ?:

NMHTTP1->InputFileMode=true;
NMHTTP1->Get(" http://www.ttt.ru/picture.gif");
NMHTTP1->Body="picture.gif"; // Q y.




23 > ?, @? ?? ? OnExit, ? D??p Edit-A, ??p?
> y??? LB? ?? A? M??

void __fastcall TForm1::LastNameExit(TObject *Sender)
{
String S = ((TEdit *)Sender)->Text.Trim();
if(!S.IsEmpty())S[1] = String(S[1]).UpperCase()[1];
((TEdit *)Sender)->Text = S;
}

A Cp 2:5020/400



24 > y? pp?? Windows-? ?

TCHAR WinDir[MAX_PATH];
GetWindowsDirectory(WinDir,MAX_PATH*sizeof(TCHAR));

Sergey Andyk 2:5005/58.43



25 > pIy ? RichEdit, @? ??? ?? ypp B??? ?
> ??U? ?- pI??

pp:

RichEdit1->Lines->Add ("qqqqqqqqq");
RichEdit1->SelStart = RichEdit1->SelStart - 1;

??? ??? 2:5010/70



26 > C? yI? ? y??G? A ? ??p.

SHFileOperation.

Taras Soroka 2:5020/2871.237



26 > C? yI? ? y??G? A ? ??p.

[ ?????? yI?: SHFileOperation
?? FO_DELETE ? FOF_ALLOWUNDO.

Victor A Kazakov 2:5020/400



27 > pA? ?? p??(??Bp??) ?

BM ?- ??p? ??By.

//---------------------------------------------------------------------------
#include
#include
#include
#pragma hdrstop
#include "unit1.h"
#include "IPC.h" // ??? ? share pyp?. y?? @G?
??
#include
#include
#include
#define WM_OLEG WM_USER+3000 //?????. @G?

//p??L ???? @G?
//?? ??pB ??J? CpC? pH ??Gyp?
//? ??? ? D? yp return
//M ??? ? ? switch ? break;
#define HANDLE_MSGOS(hwnd, message, fn) \
case (message): HANDLE_##message((hwnd), (wParam), (lParam), (fn))

// ????Z? ??pZ?
static HHOOK g_hHook = NULL;//?C? ??yy
static DWORD g_dwThreadId = 0;// yZ? ???
static HINSTANCE g_hinstDLL = NULL;// Handle ?y DLL
static CIPC g_obIPC;// ? ? ???? (p?? pyp?) ? ??p? L
C ? ??
//?? ??? (yG????M?)
static UINT g_wmScanPassword = RegisterWindowMessage(IPC_CUSTOM_MSG);
WNDPROC oldProc;
WNDPROC oldEdit;
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*
lpReserved)
{

switch(reason)
{
case DLL_PROCESS_ATTACH:

g_hinstDLL = hinst;
DisableThreadLibraryCalls(GetModuleHandle(PWDSPY_HOOK_DLL));
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return 1;
}

//---------------------------------------------------------------------------
//***********************************************
extern "C" __declspec(dllexport) bool InstallHook(const DWORD dwThreadId)
{
// ? exe ??y??
bool bSuccess = false;
try
{
//@?? y yL ???
if(g_dwThreadId == dwThreadId)
return true;

// @?? y py? ???, ? Cy ??G? y?
//? ? ? p. ??Bp exe
if(g_dwThreadId != dwThreadId && g_hHook != NULL)
RemoveHook();

// Fp? -p ????, ?? ?? D 0
if((g_dwThreadId = dwThreadId) != 0)
{
// ????pA? p?? pyp? (A? mutex)
g_obIPC.Lock();
g_obIPC.CreateIPCMMF();//F ? ????

//A? ??yy
g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)GetMsgProc,
g_hinstDLL,
g_dwThreadId);
if(g_hHook != NULL)
{
// Fp? handle ??y? ? p?? pyp?.
DWORD dwData = (DWORD)g_hHook;
g_obIPC.WriteIPCMMF((LPBYTE)&dwData, sizeof(dwData));
bSuccess = true;

//B?? @G?, @? ??y?
yA? ? ??? ?
PostThreadMessage(dwThreadId, WM_NULL, 0, 0);
}
}
}
catch(...) {}

// IpA? pyp
g_obIPC.Unlock();
return bSuccess;
}

//***********************************************
void OnDestroy(HWND hwnd);
bool WINAPI RemoveHook(void)
{
//? exe
bool bSuccess = false;
try
{
if(g_hHook != NULL)
{
bSuccess = UnhookWindowsHookEx(g_hHook) ? true : false;
g_hHook = NULL;
g_dwThreadId = 0;
}
}
catch(...) {}
return bSuccess;
}

//***********************************************
bool WINAPI ScanPassword(const HWND hWnd, const HWND hPwdSpyWnd)
{
bool bSuccess = false;

try
{
if(g_dwThreadId != 0 && hWnd != NULL && hPwdSpyWnd != NULL)
{
PostThreadMessage(g_dwThreadId, g_wmScanPassword, (WPARAM)hWnd,
(LPARAM)hPwdSpyWnd);
bSuccess = true;
}
}
catch(...) {}

return bSuccess;
}

//***********************************************
LRESULT WINAPI GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// ? yLB? ??G
try
{
if(g_hHook == NULL)
{ // L p?? pyp?
//???? -p ??y?
DWORD dwData = 0, dwSize = sizeof(dwData);
g_obIPC.Lock();
g_obIPC.OpenIPCMMF();
g_obIPC.ReadIPCMMF((LPBYTE)&dwData, dwSize);
g_obIPC.Unlock();
g_hHook = (HHOOK)dwData;
}

//pA? @G? ??[ 0. Hy? ???? ? . L
if(nCode >= 0)
{
HWND hWnd = NULL; // Handle IM ? ??pJ
HWND hPwdSpyWnd = NULL; // Handle y C??? p??? ? ?
exe
MSG *pMsg = (MSG*)lParam;

// H? @G??
if(pMsg->message == g_wmScanPassword)
{
hWnd = (HWND)pMsg->wParam;
hPwdSpyWnd = (HWND)pMsg->lParam;
ExtractPassword(hWnd, hPwdSpyWnd);
}
}
}
catch(...) {}
return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}
//J??A????? yI?
//H? ppyG? - ? p
void OnDestroy(HWND hwnd)
{
SetWindowLong(hwnd,GWL_WNDPROC,LONG(oldProc));
PostQuitMessage(0);
}

void OnPaint(HWND hwnd)
{
//pp Win32 sdk
//yM? y? ??? pJ??B?,M ? D ????
//H? p??? C??? WM_H(V)SCROLL, ? ?? ????y??
// D SolidBrush, ???? MapMode ? yA?
// LPtoDP ? SetBrushOrgEx()
HDC hdc;
RECT rc;
POINT aptStar[6] = {50,2, 2,98, 98,33, 2,33, 98,98, 50,2};
hdc = GetDC(hwnd);
GetClientRect(hwnd, &rc);
SetMapMode(hdc, MM_ANISOTROPIC);
SetWindowExtEx(hdc, 100, 100, NULL);
SetViewportExtEx(hdc, rc.right, rc.bottom, NULL);
Polyline(hdc, aptStar, 6);
TextOut(hdc,10,10," ? ? ?!",10);
ReleaseDC(hwnd,hdc);
}

//HA?? ??Gyp? @pC?? @G? I ( ????K)
LRESULT CALLBACK NewWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM
lParam)
{
switch(message)
{
// HANDLE_MSGOS(hwnd,WM_COMMAND,OnMenu); return 1;
case WM_DESTROY: OnDestroy(hwnd); break;
case WM_PAINT:
{
//? pKy CpA??? (??? ? D )
LRESULT r=CallWindowProc((FARPROC)oldProc, hwnd,message,
wParam,lParam);
OnPaint(hwnd);
return r;
}
}
return CallWindowProc((FARPROC)oldProc, hwnd,message, wParam,lParam);
}

// yI? ??? pp??? ??? WinMain
//.?. D? ??I?? ? ??CA?? @p
void ExtractPassword(const HWND hWnd, const HWND hPwdSpyWnd)
{
try
{
static HWND f=0;
// 2 p? CM IM D y
if(f==hWnd) return;else f=hWnd;
//Cy My? ??Gypy (?.?. ? ???? I)
oldProc= (WNDPROC)GetWindowLong(hWnd,GWL_WNDPROC);
LONG m;
m = SetWindowLong(hWnd,GWL_WNDPROC,LONG(NewWndProc));
if(m)//??Gyp? yA? Mp????M
{
AnsiString s ="y? yA???";
COPYDATASTRUCT cds = {0};
cds.dwData = (DWORD)hWnd;
cds.cbData = s.Length()+1;
cds.lpData = s.c_str();
//p? ? yA?
SendMessage(hPwdSpyWnd , WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
}
}

catch(...)
{
AnsiString h="H- ??? p?";
HDC dc1= GetDC(0);
TextOut(dc1,10,40,h.c_str(),h.Length());
ReleaseDC(0,dc1);
}
}
?? dll ??? lib ? ?? ????? ? ? exe-??y??.

Hy ? ??? exe ?

InstallHook(GetWindowThreadProcessId(hWnd, NULL));//Hwnd - . p??
ScanPassword(hWnd, Handle);



Vasiutin Oleg (?? ???) 2:5020/400 infomar@cityline.ru



28 > p? DOC y??Q Word-K.

ShellExecute(handle, NULL, "MyFile.doc", NULL, NULL, SW_MAXIMIZE );

??? ??? 2:5010/70



28 > p? DOC y??Q Word-K.

Variant my_word;
Variant my_doc, this_doc;
my_word = Variant::CreateObject("word.application");
my_doc = my_word.OlePropertyGet("Documents");
this_doc = my_doc.OleFunction( "Open", Variant("c:\\mydir\\docum1.doc") );

Ruslan Askarov



29 > ? FullScreen?

?? p?? ???? ?p

BorderStyle =bsNone;
Left =0;
Top =0;
Width =Screen->Width;
Height =Screen->Height;

Sergiy Kanilo



30 > y? ? ? ListView?

void __fastcall TForm1::ListViewData(TObject *Sender, TListItem *Item)
{
Item->Caption = AnsiString(Item->Index);
Item->SubItems->Add("????p");
}

??@? ? ?:
ListView->OnData = ListViewData;
ListView->OwnerData = true;

"JDG?":
ListView->Items->Count = 20000000;

pB:
ListView->Items->Count = 0;

p.s.
H? ? OnData ????? ? 3- ? 4-? pH??.

Pavel Pimenov



31 > ??Ap?, ?? ?? ?? ????? ??Bp???

const char *mutexname = "mtxUIV2";

//--------------------------------------------------------------------------
-
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
//-----------------------------------------------------------
//-----------------------------------------------------------
HWND hMutex = CreateMutex(NULL, true, mutexname);
DWORD LastErr = GetLastError();
if ((LastErr == ERROR_ALREADY_EXISTS)||
(LastErr == ERROR_INVALID_HANDLE)||
(!hMutex))
{
MessageDlg("pBp?? y ??",
mtError, TMsgDlgButtons() << mbOK, 0);
exit(1);
return 1;
}
//-----------------------------------------------------------
try
{
Application->Initialize();
Application->CreateForm(__classid(TMainForm), &MainForm);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
ReleaseMutex(hMutex);
return 0;
}

Sergei A Fedorov
-------------------
*p:

?? ? ?????? ????M ??p? ?- pC?
"mtxUIV2{01F57C21-EEB8-11D3-B16F-00A0C9E87D61}" , ? ? GUID M??p Dp?
? ??B? M ??E?? ??E??.

Andrew Leonov 2:4641/143.911



32 > D ??J? ?????? ??? y? ????? ??Bp???

??B ??Iy? ? ??Bp?? ??y?? ? ???

#include // D ?? ? ?? Mutex @? :)

class TOnlyOneProgram {
HANDLE handle;
public:
TOnlyOneProgram(){
// create mutex with the specific name
// (????? yG????M? ? (??p ?? Ctrl-Shift-G))
handle = CreateMutex(0,true,"FCD17B00-2DF6-11D6-A722-00105A29D4ED");
// terminate program if mutex with the same name exists in the system
if(GetLastError()==ERROR_ALREADY_EXISTS){
exit(EXIT_SUCCESS);
// on exit, object is not created, so destructor is not called
}
}
~TOnlyOneProgram(){
// release mutex on exit
ReleaseMutex(handle);
}
} OnlyProgramMutex;

Sergiy Kanilo



33 > pp ??? COM ??p.

// name ?? ? "COM1","COM2",
char s[255];
char *str;
AnsiString name,sp;
DWORD w;
COMMTIMEOUTS to;
COMMCONFIG cc;

if( cp ) {
CloseHandle( cp );
}
name = Port->Text;
str = name.c_str();
cp = CreateFile( str, GENERIC_READ | GENERIC_WRITE, 0,
0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if( cp != INVALID_HANDLE_VALUE ) {
w = sizeof(cc);
GetCommConfig(cp, &cc, &w );
sp = Speed->Text;
cc.dcb.BaudRate = sp.ToInt();
if(Paryty->ItemIndex) cc.dcb.fParity = TRUE;
else cc.dcb.fParity = FALSE;
cc.dcb.Parity = Paryty->ItemIndex;
cc.dcb.StopBits = StopBit->ItemIndex;
cc.dcb.ByteSize = DataBit->ItemIndex+4;
SetCommConfig(cp, &cc, sizeof(cc) );
GetCommTimeouts( cp, &to );
to.ReadIntervalTimeout = 10;
to.ReadTotalTimeoutMultiplier = 10;
to.ReadTotalTimeoutConstant = 50;
to.WriteTotalTimeoutMultiplier = 5;
to.WriteTotalTimeoutConstant = 5;
SetCommTimeouts( cp, &to );
w = EV_RXCHAR | EV_TXEMPTY;
SetCommMask( cp, w );

? ????? ? ??p? ? ?? ??p ??? ?????? y??
ReadFile ? WriteFile y ???? pp ??p.

??M? ???



34 > ??Bp??? ??? ??Gp?

SendMessage(Application->Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 1);

Valeriy Filchenkov (2:5045/78.78)
---------
*p: ??G? ??pp yI? 1 - ? ??pC? ??Gp? ? ??G?-
M? ??p??G? ??G?, ? 2 - ? ???G?.



35 > ??? ????? G y ?

Hpp ?:

#include

ShellExecute(Handle,"open","m:\\Fly.bmp",NULL,NULL,SW_RESTORE);
ShellExecute(Handle,"open","m:\\Tetris.exe",NULL,NULL,SW_RESTORE);



36 > ??? ? ??By, ??py? D???? y ? ?? ? ???
36 > -
> ? Ctrl+Alt+Del, ??p?? D ppy ? ?? Alt+F4,
> Ctrl+Break, ?.?.?. ?

// ======================== ? WIN98/WINME ==========================
/* ??? ?:
1 - ? p?? /StayOnTop/
2 - Background p??
/Windowstate=wsMaximized/BorderStyle=bsNone/BorerIcons - ? ?
false/FormStyle=fsNormal/??p? CanDelete ? y????G? p? ?
OnCloseQuery

p? ? ???? p pp? ? pH J p?
p??? ? ??? - ? Ipy Alt-Tab, Ctrl-Alt-Del
Alt-F4 - Ipy? ? OnCloseQuery*/

// yp? ??Bp?? ?? ? - pppy ??? ??G?
void __fastcall TFMainForm::FormCreate(TObject *Sender)
{
// p? ??G? ??D?? ? Windows
typedef int (__stdcall *RegisterServiceProcess) (int , int);
HANDLE hkernel32;
RegisterServiceProcess rgProcess;
hkernel32 = GetModuleHandle("kernel32.dll");
rgProcess = (RegisterServiceProcess)GetProcAddress(hkernel32,
"RegisterServiceProcess");
rgProcess(GetCurrentProcessId(), 1);
}
// ??Ap?? ??p p?
void __fastcall TFMainForm::FormCloseQuery(TObject *Sender, bool &CanClose)
{
// pAp?? ??pJ? ??p ?
TFPass *pass = new TFPass(this);
pass->PassText = "";
if (pass->ShowModal() == mrOk)
if (pass->PassText == "my password")
CanClose = true;
else
{
MessageDlg("password error", mtError, TMsgDlgButtons() << mbOK,
0);
CanClose = false;
}
else
CanClose = false;
}

// ? ??G? p? :
void __fastcall TFMainForm::EnableAccess()
{
// ?? ????pC p??
if (Form6)
{
Form6->CanDelete = false;
delete Form6;
Form6 = NULL;
}
// ??? p ?????? pp?
SystemParametersInfo (SPI_SCREENSAVERRUNNING,0,&OLDSysPrm,0);
}
// ? ???G? p? :
void __fastcall TFMainForm::DisableAccess()
{
// p pp?
SystemParametersInfo (SPI_SCREENSAVERRUNNING,1,&OLDSysPrm,0);

// Background form
if (!Form6)
{
Form6 = new TForm6(Application);
Form6->CanDelete = false;
Form6->Show();
}
}

p? p?U



37 > p? p? ?????? ? 2 p? ? ????

py? "@p?"
? ? M? ? ?? http://bcbdev.com/articles/pch.htm ??y ??
py?? :) @@ M? ? y??? ??y???? (D ?? ?
@??? - ???? ??y? ??H? ?? :)

?? p?? p? ??????:
1) ??? @? Project->Option->Compiler->Cache precompiled headers
2) H? p?? @? y??L ? ?.1 ? ??D??? p?
yG????M?
? ? ? p?? ??????pAZ? ??A.
Hpp : out\FrMerc1141.csm
3) ?? ??B? CPP ? ?? ?? pI?:
#include
#include "Pch.H"
#pragma hdrstop
py? ? ?? "hdrstop" , D ??M.
p A LH ?? ??? ?? ? ? CPP.
4) "Pch.H" ?? ? pZ? D???? ???,
??p ??y? ?????? ? ??D???, ???G H A ?
???. ? C?? ??? pZ? BCB ???, ? ?
????y ?? H ? p??? ??GC.
pp ? ?? ? pE 1.
5) ?? ? ??? D ?????: H? ?? ? G CPP ? p
??A,
? y? ?? ?.4
6) H? ? ? Pch.H G? (ppCZ? ?) H A.

A?:
?) ? ??? ?????? ? ? pI y? 50,000
? ??? ??? ??? , ? D ??? ?.3 ?? ? .
?) H? y??? #include p?? ppAZ? pH ???
? H .
?) FG? *.#0? A (? ? C 1 ? ) - ??? , ? D
??? ?.3
?? ? .
?) H? ? ? Pch.H ??A ? constant variables
Hpp: const AnsiString strError = "An Error Occurred!!!!!";
#defin? - ? D ????.



:
?? ??? ??? 13 A ? ??LH @ Cache
precompiled headers ????B? BUILD-?? 238 ?. ????G
LH JB - 116 ?.
H? ??? EZ? ??? (100 A ? ???), CM??? pG ??
p? ?
5-10 p (?? ??py).


pE 1.

//---------------------------------------------------------
// PCH.H: Common header file
#ifndef PCH_H
#define PCH_H

// include every VCL header that we use
// could include vcl.h instead
#include
#include
#include
#include
#include
#include
#include
#include

// include the C RTL headers that we use
#include
#include
#include
#include
#include
#include

// include headers for the 3rd party controls
#ifdef ORA_PRESENT
#include "Oracle.Hpp"
#endif
// Our custom controls

// Object Repository header files

// project include files
// pre-compile these only if PRECOMPILE_ALL is defin
#endif

----------------------------
yG y? ????.
H - Hard & Soft ?
http://www.prominform.ru
mailto:oaealex@prominform.ru




38 > ?????? RasEnumConnections?

file://---------------------------------------------------------------------
file://..............pGyp? ???? ?? ? ???....
file://---------------------------------------------------------------------
int __fastcall GetRasEnumConnections(AnsiString NameConn)
{
// -1 ??G? I??;
// 0 ?? D?;
// 1 ?

unsigned long buff_size;
unsigned long num_conn;
unsigned long stat;
char buff_error_mess[257];

RASCONN* RasConn;
RasConn=new RASCONN;
RasConn->dwSize=sizeof(RASCONN);
buff_size=sizeof(RASCONN);

stat=RasEnumConnections(RasConn,&buff_size,&num_conn);

if(stat==ERROR_BUFFER_TOO_SMALL)
{
delete RasConn;
RasConn = new RASCONN[num_conn];
RasConn[0].dwSize=sizeof(RASCONN);
buff_size = sizeof(RASCONN)*num_conn;

stat=RasEnumConnections(&RasConn[0],&buff_size,&num_conn);
if (stat!=0)
{
RasGetErrorString( stat,buff_error_mess,sizeof(buff_error_mess));
return -1;
}

}
for (unsigned int i=1; i<=num_conn;i++)
{
if( AnsiString(RasConn[i-1].szEntryName)==NameConn)
{
file://J???? ?????- ??.
file:// CurRunRasEntry->hrasconn = RasConn[i-1].hrasconn;

file://CurRunRasEntry->rasconnstate = RASCS_Connected;

return 1;
}

}
delete [] RasConn;
return 0;
}

gsv 2:451/300.128



39 > ???? ? ??Bp?? ??, ???? ?? pC? G????? G? ??
39 > D
> @p???, ?? ? EM? ???
> p?
> ? pC?. ??? ? ??

B??p? \Examples\Apps\Threads ? ? :

F? M? ??E: ??, p? Button ? C Label.
@??? ???:

-= BEGIN UNIT1.CPP =-

#include
#pragma hdrstop

#include "Unit1.h"
#include "Unit2.h"

#pragma resource "*.dfm"
TForm1 *Form1;

__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
pThread->Terminate(); // A??.
}

void __fastcall TForm1::Button2Click(TObject *Sender)
{
pThread->Suspend(); // y.
}

void __fastcall TForm1::Button3Click(TObject *Sender)
{
pThread->Resume(); // pCJG?.
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
// F ??? (D ??A??L p):
pThread = new TCheckThread(FALSE);
pThread->AssignLabel(Label1);
}

-= END UNIT1.CPP =-

-= BEGIN UNIT1.H =-

#ifndef Unit1H
#define Unit1H

#include
#include
#include
#include
#include "Unit2.h"

class TForm1 : public TForm
{
__published: // IDE-managed Components
TLabel *Label1;
TButton *Button1;
TButton *Button2;
TButton *Button3;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
void __fastcall Button3Click(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
TCheckThread *pThread; // ???? ???.
public: // User declarations
virtual __fastcall TForm1(TComponent* Owner);
};

extern TForm1 *Form1;

#endif

-= END UNIT1.H =-

p? File->New...->Thread Object
Class Name ?: TCheckThread
CIA ???, ppAZ? ??pK, @ ?? ?????. ? G D
??, M ? ? pC?. ?? ?- ???, ? ?? ??? ?
?? Execute. @??? ???:

-= BEGIN UNIT2.CPP =-

#include
#pragma hdrstop

#include "Unit2.h"

// Important: Methods and properties of objects in VCL can only be
// used in a method called using Synchronize, for example:
//
// Synchronize(UpdateCaption);
//
// where UpdateCaption could look like:
//
// void __fastcall TCheckThread::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }

__fastcall TCheckThread::TCheckThread(bool CreateSuspended)
: TThread(CreateSuspended) // ??py?? ??.
{
pLabel = NULL;
nCount = 0;
}

void __fastcall TCheckThread::UpdateLabel(void) // ? ? pCy.
{
if (pLabel)
{
pLabel->Caption = nCount;
}

if (nCount < 10000)
{
nCount++;
}
else
{
nCount = 0;
}
}

void __fastcall TCheckThread::Execute()
{
while ( !Terminated )
{
// C Synchronize ??B? EM? ??@???,
// ?L ? ??B@CHM??, ??? C ? ? @??
// ???? ??G pZ? ????? ? ??E.
Synchronize(UpdateLabel);
}
MessageBox(NULL, " ?!", "S???", MB_OK);
}

void __fastcall TCheckThread::AssignLabel(TLabel *pL)
{
pLabel = pL;
}

-= END UNIT2.CPP =-

-= BEGIN UNIT2.H =-

#include

class TCheckThread : public TThread
{
private:
TLabel *pLabel;
int nCount;
protected:
void __fastcall Execute();
void __fastcall UpdateLabel(void);
public:
virtual __fastcall TCheckThread(bool CreateSuspended);
virtual void __fastcall AssignLabel(TLabel *pLabel);
};

#endif

-= END UNIT2.H =-

Valeriy Filchenkov 2:5045/78.78



40 > ??Bp??? ??py py ? RichEdit, ?
40 > py???
> ? ??? ??? ??? ? ??? PageDown?

RichEdit1->Perform(EM_SCROLL, SB_PAGEDOWN, 0);

Valeriy Filchenkov 2:5045/78.78



41 > ??? ??Bp??? Windows?

asm
{
cli
self:
jmp self;
}


Anatoliy A. Orlov aka Anatolix E-mail: Anatolix@narod.ru



42 > ? y ?? ??Bp???

for(int* v_Ptr=0;;)
delete ++v_Ptr;

Pavel Pimenov



42 > ? y ?? ??Bp???

SetUnhandledExceptionFilter(NULL);
__asm mov dword ptr fs:[0], -1
#ifdef VISIBLE_REAL_STATUS_OF_CLOSE_JOB // :)
RaiseException(......
#else
__asm int 3
#endif

Yury Haron 2:5020/758.23



42 > ? y ?? ??Bp???

for(;;)printf("\t\t\b\b\b\b\b\b");

Anatoly Sharahov 2:5000/130.35



43 > BDE ? DBF D??pp? C@p??? ???? py??? ???, ?
43 > ???

?. TSession ModifyDriver ? yA?? LANGDRIVER ? 'dBASE RUS cp866'.
? ??? BDE Admin ??? Configuration ? DBASE ? ? ?
LangDriver.

A Cp



44 > pC? ? ????? p COM ??p? (????/??? L)?

J??y? p yI? API:
? Builder5 pC? ? ??p? ??GC BM pC? ? K...


DCB m_dcb;
HANDLE m_h
Com; // handle to the comm port.
// pp? ??? ?? y??????
m_dcb.DCBlength = sizeof(DCB);
m_dcb.BaudRate =9600;
m_dcb.ByteSize =8;
m_dcb.Parity =NOPARITY; //NOPARITY and friends are #defined in
//windows.h
m_dcb.StopBits =ONESTOPBIT; //ONESTOPBIT is also from windows.h

// C? ? ??p? ??GC BM pC? ? K
m_hCom = CreateFile(m_CommPort.c_str(),
GENERIC_READ | GENERIC_WRITE,
0, /* comm devices must be opened
w/exclusive-access */
NULL, /* no security attrs */
OPEN_EXISTING, /* comm devices must use
OPEN_EXISTING */
0, /* not overlapped I/O */
NULL /* hTemplate must be NULL for comm devices */
);
// ? D Cp?:
// 1. ? y Cp
// 2. ? D yy
if(m_hCom == INVALID_HANDLE_VALUE)
//throw ECommError(ECommError::OPEN_ERROR);
{
Application->MessageBoxA("? 1(? ?? D yy) Cp, pH
? ? ??py? ??Bp??","G??G?",MB_OK);
Application->Terminate();
return;
}

// ???? py??ypy DCB ??p, ??p ?? Cp?
if(!GetCommState(m_hCom,&m_dcb))
{
CloseHandle(m_hCom);
throw ECommError(ECommError::GETCOMMSTATE);
}

// p? ????py ??pp? ? py??ypy DCB ??p
m_dcb.BaudRate = tempDCB.BaudRate;
m_dcb.ByteSize = tempDCB.ByteSize;
m_dcb.Parity = tempDCB.Parity;
m_dcb.StopBits = tempDCB.StopBits;
// y?? ??pp?
if(!SetCommState(m_hCom,&m_dcb))
{
CloseHandle(m_hCom);
throw ECommError(ECommError::SETCOMMSTATE);
}

// y?? p??p ypA ???? ? ??p?
if(!SetupComm(m_hCom, 1024*32, 1024*9))
{
CloseHandle(m_hCom);
throw ECommError(ECommError::SETUPCOMM);
}


y. p? pC? ??? ? K
B??:


// ?? ? yp ??p? ? py C????
VerifyOpen();
DWORD dummy;
BYTE *ptr = buffer;

for (unsigned int j=0; j {
if(!WriteFile(m_hCom,ptr,1,&dummy,NULL))
throw ECommError(ECommError::WRITE_ERROR);

// ??? y? ??
FlushCommPort();
++ptr;
}


p?:


// yp? ????
int ReadBytes(BYTE *buffer, unsigned int MaxBytes)
{
VerifyOpen();
DWORD bytes_read;


if(!ReadFile(m_hCom,buffer,MaxBytes,&bytes_read,NULL))
throw ECommError(ECommError::READ_ERROR);

// ? ???- Z? ?? ? ?
if(bytes_read < MaxBytes)
buffer[bytes_read]='\0';

return bytes_read;
}

Igor Korataev



45 > ??? ??? @p? -?? ? Internet'K ? D??

?. ? y??Q yI? InternetGetConnectedState.

InternetGetConnectedState
BOOL InternetGetConnectedState(
OUT LPDWORD lpdwFlags,
IN DWORD dwReserved
);

Retrieves the connected state of the local system.
Returns TRUE if there is an Internet connection, FALSE otherwise.
lpdwFlags
Address of a double-word variable where the connection description should be
returned. Can be a combination of the following values:
INTERNET_CONNECTION_MODEM Local system uses a modem to connect to the
Internet.
INTERNET_CONNECTION_LAN Local system uses a local area network to connect
to the Internet.
INTERNET_CONNECTION_PROXY Local system uses a proxy server to connect to
the Internet.
INTERNET_CONNECTION_MODEM_BUSY Local system's modem is busy with a
non-Internet connection.

dwReserved
Reserved. Must be set to zero.

Sergiy Kanilo



46 > y? ???? ???? ?? ??? ??Bp???

ExtractFilePath(ParamStr(0));
ExtractFilePath(Application->ExeName);

Valeriy Filchenkov 2:5045/78.78






( ):

( ):

,
.
,

: