亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? icsdll1.cpp

?? 文件名稱:新曦 我的資源 搜索軟件 源程序(Borland Delphi 7)說明
?? CPP
字號:
/*---------------------------------------------------------------------------

Author:       Fran鏾is PIETTE
Creation:     April 08, 2000
Description:  This is a demo showing how to use a TWSocket component in a DLL.
              This demo must be used with ICS TcpSrv demo program as a server.
              The DLL is a client which connect to the server and send "time"
              command, then wait for the reply and return it in the buffer
              passed to the DLL.
              There is only one function exported from the DLL: IcsDllDemo.
              It takes four arguments: a pointer to the hostname to connect to,
              a pointer to the port, a pointer to a buffer and a pointer for
              buffer size. On entry buffer size must be initialised with the
              size of the actual buffer. On exit, it is filled with the
              actual reply size. The function's return value is the error code
              such as 10061 when the server is not running.
Version:      1.00
EMail:        francois.piette@pophost.eunet.be    francois.piette@swing.be
              francois.piette@rtfm.be             http://www.rtfm.be/fpiette
Support:      Use the mailing list twsocket@rtfm.be See website for details.
Legal issues: Copyright (C) 2000 by Fran鏾is PIETTE
              Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
              <francois.piette@pophost.eunet.be><francois.piette@swing.be>

              This software is provided 'as-is', without any express or
              implied warranty.  In no event will the author be held liable
              for any  damages arising from the use of this software.

              Permission is granted to anyone to use this software for any
              purpose, including commercial applications, and to alter it
              and redistribute it freely, subject to the following
              restrictions:

              1. The origin of this software must not be misrepresented,
                 you must not claim that you wrote the original software.
                 If you use this software in a product, an acknowledgment
                 in the product documentation would be appreciated but is
                 not required.

              2. Altered source versions must be plainly marked as such, and
                 must not be misrepresented as being the original software.

              3. This notice may not be removed or altered from any source
                 distribution.

              4. You must register this software by sending a picture postcard
                 to the author. Use a nice stamp and mention your name, street
                 address, EMail address and any comment you like to say.

History:


---------------------------------------------------------------------------*/
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma argsused
#include "WSocket.hpp"
//---------------------------------------------------------------------------
extern "C" __declspec(dllexport) int __stdcall IcsDllDemo(char *HostName,
                                                          char *Port,
                                                          char *Buffer,
                                                          int  *BufSize);
void StrToBuffer(char *Buffer, int *BufSize, char *Msg);
//---------------------------------------------------------------------------
// We use a workerthread to do the job.
// This will allows the DLL to be called by several processes simultaneously
class TClientThread : public TThread
{
private:
    TWSocket *FClientSocket;
    void __fastcall ClientWSocketDataAvailable(TObject *Sender, WORD Error);
    void __fastcall ClientWSocketSessionClosed(TObject *Sender, WORD Error);
    void __fastcall ClientWSocketSessionConnected(TObject *Sender, WORD Error);
protected:
    AnsiString FHostName;
    AnsiString FPort;
    int        *FErrorCode;
    BOOL       FBannerReceived;
    char       *FBuffer;
    int        *FBufSize;
    void __fastcall Execute();
public:
    __fastcall TClientThread();
    __fastcall ~TClientThread();
    __property char      *Buffer    = {read=FBuffer,    write=FBuffer};
    __property int       *BufSize   = {read=FBufSize,   write=FBufSize};
    __property int       *ErrorCode = {read=FErrorCode, write=FErrorCode};
    __property AnsiString HostName  = {read=FHostName,  write=FHostName};
    __property AnsiString Port      = {read=FPort,      write=FPort};
};
//---------------------------------------------------------------------------
// Create a new thread in the blocked state. This allow the user to register
// the client thread before it actually start working.
__fastcall TClientThread::TClientThread()
    : TThread(TRUE)
{
    FreeOnTerminate = TRUE;
}
//---------------------------------------------------------------------------
// Destroy the thread. Destroy the ClientWSocket if needed.
__fastcall TClientThread::~TClientThread()
{
    if (FClientSocket != NULL) {
         FClientSocket->~TWSocket();
         FClientSocket = NULL;
    }
}
//---------------------------------------------------------------------------
// This is the main thread routine. There is not much to do because TWSocket
// is event drive. So everythong to do is done inside an event handler,
// mostly the OnDataAvailable event handler which is triggered each time
// something is received.
void __fastcall TClientThread::Execute()
{
    try {
        // Create the client TWSocket. It is important to create it inside the
        // Execute method because it *must* be created by the thread. Otherwise
        // the messages sent by winsock would be processed in the main thread
        // context, effectively disabling multi-threading.
        FClientSocket                     = new TWSocket(NULL);
        FClientSocket->OnDataAvailable    = ClientWSocketDataAvailable;
        FClientSocket->OnSessionConnected = ClientWSocketSessionConnected;
        FClientSocket->OnSessionClosed    = ClientWSocketSessionClosed;
        FClientSocket->LineMode           = TRUE;
        FClientSocket->Addr               = FHostName;
        FClientSocket->Port               = FPort;
        FClientSocket->Proto              = "tcp";
        FClientSocket->Connect();

        // Message loop to handle TWSocket messages
        // The loop is exited when WM_QUIT message is received
        FClientSocket->MessageLoop();
    }
    catch (Exception &E)
    {
        AnsiString Buf;
        Buf = E.ClassName();
        Buf = Buf  + ": " + E.Message;
        *FErrorCode = -3;
        StrToBuffer(Buffer, BufSize, Buf.c_str());
    }

    // Returning from the Execute function effectively terminate the thread
}
//---------------------------------------------------------------------------
// This event handler is called when the client connection is established.
void __fastcall TClientThread::ClientWSocketSessionConnected(
    TObject *Sender, WORD Error)
{
    if (Error) {
        *FErrorCode = Error;
        StrToBuffer(Buffer, BufSize, "Connect failed");
        PostMessage(FClientSocket->Handle, WM_QUIT, 0, 0);
    }
}
//---------------------------------------------------------------------------
// This event handler is called when the client connection is closed.
void __fastcall TClientThread::ClientWSocketSessionClosed(
    TObject *Sender, WORD Error)
{
    PostMessage(FClientSocket->Handle, WM_QUIT, 0, 0);
}
//---------------------------------------------------------------------------
// This event handler is called when data has been received from server.
// Since this sample program use line mode, we comes here only when a
// complete line has been received.
void __fastcall TClientThread::ClientWSocketDataAvailable(
    TObject *Sender, WORD Error)
{
    AnsiString RcvBuffer;

    // Received the line
    RcvBuffer = FClientSocket->ReceiveStr();
    // Check if we already received the banner (message sent by server
    // as soon as we are connected.
    if (!FBannerReceived) {
        // We are just receiving the banner. Flag as received
        FBannerReceived = TRUE;
        // Then send the command to the server
        FClientSocket->SendStr("time\r\n");
    }
    else {
        // We already received then banner. So this must be the answer
        // to our command. Copy to the buffer, without trailling CR/LF
        // and without overflowing the given buffer
        if (RcvBuffer.Length() < *BufSize)
            *BufSize = RcvBuffer.Length() - 2;  // Remove CR/LF
        if (*BufSize > 0)
            memcpy(Buffer, RcvBuffer.data(), *BufSize);
        // Then just close the communication
        FClientSocket->CloseDelayed();
        *FErrorCode = 0;
    }
}
//---------------------------------------------------------------------------
// Copy a string to a buffer with overflow check.
void StrToBuffer(char *Buffer, int *BufSize, char *Msg)
{
    int Len;

    if ((Len = strlen(Msg)) < *BufSize)
        *BufSize = Len;
    if (*BufSize > 0)
        memcpy(Buffer, Msg, *BufSize);
}
//---------------------------------------------------------------------------
// This is the function exported from the DLL. It is intended to be called
// from the application using the DLL.
int __stdcall IcsDllDemo(
    char *HostName,
    char *Port,
    char *Buffer,
    int  *BufSize)
{
    TClientThread *WorkerThread;
    int           Result;

    try {
        Result = -1;
        // Create a new thread. It is created in sleeping state
        WorkerThread           = new TClientThread;
        // Then pass all parameters
        WorkerThread->Buffer    = Buffer;
        WorkerThread->BufSize   = BufSize;
        WorkerThread->ErrorCode = &Result;
        WorkerThread->HostName  = HostName;
        WorkerThread->Port      = Port;
        // Then let thread start his work
        WorkerThread->Resume();
        // And wait until it finishes
        WaitForSingleObject((void *)WorkerThread->Handle, INFINITE);
    }
    catch (Exception &E)
    {
        AnsiString Buf;
        Buf = E.ClassName();
        Buf = Buf + ": " + E.Message;
        Result = -2;
        StrToBuffer(Buffer, BufSize, Buf.c_str());
    }
    return(Result);
};
//---------------------------------------------------------------------------
// This function is called by Windows when the DLL is loaded/unloaded and
// each time a thread attach/detach from the DLL
BOOL WINAPI DllEntryPoint(
    HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
    switch (fwdreason) {
    case DLL_PROCESS_ATTACH:
        // Increment WSocket reference count. This will make sure winsock will
        // remains loaded. This is because there is no permanent TWSocket
        // component created.
        WSocketGCount++;
        // This will load winsock and call WSAStartup
        WSocketGetProc("");
        break;
    case DLL_PROCESS_DETACH:
        // Decrement WSocket reference count.
        WSocketGCount--;
        // If reference count goes to zero, then unload winsock.
        if (WSocketGCount <= 0) {
            WSocketUnloadWinsock();
            WSocketGCount = 0;
        }
        break;
    }
    return(1);
}
//---------------------------------------------------------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩在线播| 久久久久高清精品| www激情久久| 亚洲一区在线视频观看| 国产一本一道久久香蕉| 一本一道波多野结衣一区二区| 成人永久免费视频| 日韩三级视频在线看| 国产精品免费视频网站| 午夜精品久久久| 成人午夜视频免费看| 久久亚洲二区三区| 亚洲欧美激情一区二区| 免费在线观看日韩欧美| 99视频精品在线| 日韩精品一区二区三区视频| 国产精品天美传媒沈樵| 午夜久久久久久久久久一区二区| 国产成人在线看| 欧美视频精品在线观看| 国产欧美日产一区| 日韩激情在线观看| 99综合电影在线视频| 精品国产一区二区三区四区四| 专区另类欧美日韩| 国产suv精品一区二区三区| 欧美日韩一区视频| 综合自拍亚洲综合图不卡区| 欧美aaaaa成人免费观看视频| 色综合天天综合给合国产| 2023国产精品| 奇米影视7777精品一区二区| 91视频在线观看| 国产丝袜欧美中文另类| 天涯成人国产亚洲精品一区av| 丰满白嫩尤物一区二区| 精品动漫一区二区三区在线观看| 亚洲国产精品久久久久秋霞影院 | 亚洲美女精品一区| 国产成人啪午夜精品网站男同| 制服丝袜亚洲色图| 亚洲国产日日夜夜| 91福利视频网站| 亚洲色图一区二区三区| 99精品视频在线观看免费| 国产拍欧美日韩视频二区| 久久精品72免费观看| 91精品国产综合久久精品图片| 亚洲精品综合在线| 99re热这里只有精品视频| 国产精品视频线看| 高清不卡一二三区| 国产亚洲制服色| 丁香婷婷深情五月亚洲| 欧美精彩视频一区二区三区| 国产成人精品免费网站| 欧美精品xxxxbbbb| 日韩国产欧美三级| 91精品蜜臀在线一区尤物| 日本va欧美va精品| 日韩欧美123| 精品一区二区三区视频| 国产午夜精品美女毛片视频| 国产suv精品一区二区883| 久99久精品视频免费观看| 日韩欧美在线观看一区二区三区| 男男视频亚洲欧美| 精品国产一区a| 久久不见久久见免费视频1| 久久久www成人免费无遮挡大片| 国产成人免费视频| 国产精品女人毛片| 欧美在线观看你懂的| 日韩主播视频在线| 精品国产乱码久久久久久图片| 国产成人精品免费在线| 亚洲男帅同性gay1069| 欧美日韩国产中文| 国产又粗又猛又爽又黄91精品| 国产色91在线| 欧美日韩一区二区不卡| 久久精品久久99精品久久| 国产日韩精品一区| 欧美视频在线观看一区| 美女脱光内衣内裤视频久久影院| 国产午夜精品美女毛片视频| 色香蕉成人二区免费| 蜜臀精品久久久久久蜜臀| 中文字幕欧美日本乱码一线二线 | 日韩一区二区高清| 成人国产亚洲欧美成人综合网| 亚洲精品一二三| 欧美美女bb生活片| 国产不卡视频一区二区三区| 亚洲一区二区三区视频在线播放| 欧美成人三级在线| 一本色道a无线码一区v| 精品一区二区免费视频| 亚洲一区在线看| 久久亚洲精精品中文字幕早川悠里 | 免费成人av在线播放| 中文字幕乱码一区二区免费| 欧美精品成人一区二区三区四区| 国产高清精品在线| 日本成人在线网站| 亚洲欧美综合网| 国产亚洲短视频| 欧美一区二区三区小说| 在线看国产一区二区| 国产成人精品www牛牛影视| 爽好久久久欧美精品| 日韩一区日韩二区| 久久久精品日韩欧美| 欧美日韩久久久| 91麻豆精品在线观看| 国产精品一区二区免费不卡| 日韩成人午夜精品| 一区二区三区成人在线视频| 国产欧美日韩一区二区三区在线观看 | 麻豆视频观看网址久久| 日韩毛片高清在线播放| 亚洲综合色网站| 中文字幕欧美国产| 欧美日韩精品免费观看视频| 成人av网址在线观看| 国产精品自拍三区| 久久精品国产亚洲一区二区三区| 国产欧美日韩三区| 精品欧美黑人一区二区三区| 欧美日韩国产一级| 91亚洲精品乱码久久久久久蜜桃| 国产一区高清在线| 夜色激情一区二区| 亚洲靠逼com| 亚洲欧美影音先锋| 国产精品久久久久9999吃药| 精品女同一区二区| 日韩欧美不卡一区| 日韩一区二区在线看片| 欧美男人的天堂一二区| 欧美三级资源在线| 99精品国产视频| 国产麻豆精品一区二区| 国产 日韩 欧美大片| 不卡一区二区三区四区| 成人国产精品免费网站| 成人美女在线视频| 91在线视频免费观看| 国产suv精品一区二区883| 不卡一区二区在线| 在线观看国产91| 91精品午夜视频| 精品国产一区二区三区忘忧草| 国产区在线观看成人精品| 椎名由奈av一区二区三区| 亚洲国产精品久久艾草纯爱| 人人狠狠综合久久亚洲| 极品美女销魂一区二区三区免费| 国产露脸91国语对白| 99久久夜色精品国产网站| 欧美性大战久久久久久久蜜臀| 91精品中文字幕一区二区三区| 欧美不卡一二三| 国产精品二三区| 亚洲不卡在线观看| 激情久久久久久久久久久久久久久久| 国产精品911| 欧美日韩国产小视频| 欧美大胆人体bbbb| 国产精品免费视频网站| 五月天丁香久久| 国产精品一区免费视频| 91高清视频在线| 久久久久久黄色| 亚洲v中文字幕| 蜜桃av一区二区三区电影| 国产麻豆欧美日韩一区| av亚洲精华国产精华精华| 99热精品一区二区| 欧美日韩精品久久久| 国产精品成人在线观看| 亚洲最新视频在线播放| 国产精品一区二区视频| 欧美日韩国产首页在线观看| 久久午夜国产精品| 五月天丁香久久| 一本色道亚洲精品aⅴ| 久久久久久日产精品| 日韩综合小视频| 色婷婷综合在线| 欧美激情自拍偷拍| 欧美日韩国产免费一区二区| 中文乱码免费一区二区| 青青草97国产精品免费观看 | 午夜电影久久久| 成人av先锋影音| 国产欧美日韩中文久久| 久久激情五月激情| 欧美裸体一区二区三区| 亚洲婷婷综合久久一本伊一区|