Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[14846] c 코드를 델파이로 포팅 중 Pointer 타입 캐스팅 문제에 대해서 도움을 요청드립니다.
이창수 [waytogo] 2236 읽음    2013-11-13 19:01
참고: http://msdn.microsoft.com/en-us/library/windows/desktop/dd834943.aspx

위에 있는 코드를 델파이로 포팅 중에 제대로 작동이 되는 부분이 있어서 도움을 요청드립니다.

#include <stdio.h>
#include <windows.h>
#include "wimgapi.h"
#pragma comment(lib, "wimgapi.lib")
//
// Callback function:
//
DWORD
WINAPI
SampleCaptureCallback(
    DWORD dwMsgId,   // Message ID
    WPARAM wParam,   // Usually a file name
    LPARAM lParam,   // Usually an error code
    PVOID pvIgnored  // Used to maintain caller context. Not used in this code sample.^
    )
{
    PBOOL pbCancel = NULL;

// BOOL *msg_back = (BOOL *)lParam;

    switch (dwMsgId)
    {
        case WIM_MSG_PROCESS:
            if (     wcsstr((PWSTR)wParam, TEXT("\\hiberfil.sys"))              ||
                wcsstr((PWSTR)wParam, TEXT("\\pagefile.sys"))              ||
                wcsstr((PWSTR)wParam, TEXT("\\System Volume Information")) ||
                wcsstr((PWSTR)wParam, TEXT("\\$Recycle.Bin"))                  ||
                wcsstr((PWSTR)wParam, TEXT("\\Windows\\CSC"))                  )
            {
                wprintf(L">>>> FilePath: %s\n", (PWSTR)wParam);
            //    *msg_back = FALSE;
                pbCancel = (PBOOL)lParam;
                                *pbCancel = FALSE;
                break;
            }
            wprintf(L"FilePath: %s\n", (PWSTR)wParam);

            // To cancel processing on this file, use:
            //
            // pbCancel = (PBOOL)lParam;
            // *pbCancel = TRUE;

            break;

        case WIM_MSG_ERROR:

            // This message is sent when an error is reported.
            //
            wprintf(L"ERROR: %s [err = %d]\n", (PWSTR)wParam, (DWORD)lParam);
            break;

        case WIM_MSG_RETRY:

            // This message is sent when the file is being reapplied because of a
            // network timeout. Retry is attempted up to five times.
            //
            wprintf(L"RETRY: %s [err = %d]\n", (PWSTR)wParam, (DWORD)lParam);
            break;

        case WIM_MSG_INFO:

            // This message is sent when an informational message is available.
            //
            wprintf(L"INFO: %s [err = %d]\n", (PWSTR)wParam, (DWORD)lParam);
            break;

        case WIM_MSG_WARNING:

            // This message is sent when a warning message is available.
            //
            wprintf(L"WARNING: %s [err = %d]\n", (PWSTR)wParam, (DWORD)lParam);
            break;
    }

    //
    // To abort image processing, return WIM_MSG_ABORT_IMAGE. Not all message types
    // check for this status. When you decide to cancel an image, it may take repeated
    // returns of this status before WIMGAPI can perform the cancelation.
    //

    return WIM_MSG_SUCCESS;
}

위의 컬백함수에서
지금 제게 문제가 되는 부분은 코드 중에...

                pbCancel = (PBOOL)lParam;
                                *pbCancel = FALSE;
이 부분입니다.
이미지로 캡처를 하려는 원본에 지정한 파일이 있으면 제외하고 캡처를 하는 부분인데...
VC++로 빌드를 해보면 원하는대로 잘 처리가 됩니다.
참고로 pbCancel을 주석 처리하고 지금 주석처리 되어있는

                                BOOL *msg_back = (BOOL *)lParam;
                                *msg_back = FALSE;

이렇게 해도 되고, 두 개가 다 잘 작옹을 합니다.

그런데 델파이에서는 제가 포인터의 타입캐스팅에 문외한이라 그런지 별 짓을 다 해봐도 원하는 결과를 얻을 수가 없습니다.
어떻게 해야할지 부디 도움을 요청드립니다.

감사합니다.

+ -

관련 글 리스트
14846 c 코드를 델파이로 포팅 중 Pointer 타입 캐스팅 문제에 대해서 도움을 요청드립니다. 이창수 2236 2013/11/13
14848     Re:c 코드를 델파이로 포팅 중 Pointer 타입 캐스팅 문제에 대해서 도움을 요청드립니다. kylix 2071 2013/11/13
14849         Re:Re:c 코드를 델파이로 포팅 중 Pointer 타입 캐스팅 문제에 대해서 도움을 요청드립니다. 이창수 1877 2013/11/13
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.