|
아래와 같이 하면 될텐데요...
EnumWindows((WNDENUMPROC)CloseExplorer, 0);
암흑사제 님이 쓰신 글 :
: 제가 하려는 것은 작업관리자에 잇는 응용프로그램에 실행되고 있는 실행파일명들을 가져오려고 하거든요
: 그래서 진행을 하려고 보니 콜백함수를 사용하여 나타나게 되었습니다.
: 콜백함수를 사용하는데 계속 오류가 나오네요
: //---------------------------------------------------------------------------
: // ==============================Unit1.cpp===================================
: #include <vcl.h>
: #include <stdio.h>
: #pragma hdrstop
: #include <DateUtils.hpp>
: #include "Unit1.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner)
: : TForm(Owner)
: {
: EnumWindows(CloseExplorer, 0);
: }
: //---------------------------------------------------------------------------
: BOOL CALLBACK TForm1 ::CloseExplorer(HWND hwnd, LPARAM lParam)
: {
: CHAR buf[100];
: AnsiString szMsg;
: szMsg = "test";
: GetClassName (hwnd, (LPTSTR)&buf, 100);
: if ( strcmp( buf, szMsg.c_str() ) != 0 )
: PostMessage(hwnd, WM_CLOSE, 0, 0); //ExplorerwClass는 스파이+에서 찾으셈..
: return true;
: }
:
:
: //---------------------------------------------------------------------------
: // ==============================Unit1.h===================================
: #ifndef Unit1H
: #define Unit1H
: //---------------------------------------------------------------------------
: #include <Classes.hpp>
: #include <Controls.hpp>
: #include <StdCtrls.hpp>
: #include <Forms.hpp>
: //---------------------------------------------------------------------------
: class TForm1 : public TForm
: {
: __published: // IDE-managed Components
: TButton *Button1;
: private: // User declarations
: public: // User declarations
: __fastcall TForm1(TComponent* Owner);
: static BOOL CALLBACK CloseExplorer(HWND hwnd, LPARAM lParam);//선언
: };
: //---------------------------------------------------------------------------
: extern PACKAGE TForm1 *Form1;
: //---------------------------------------------------------------------------
: #endif
:
: 오류
: [C++ Error] Unit1.cpp(16):E2034 Cannot convert 'int (__stdcall *)(void*,long)'to'int(__stdcall*)()'
: [C++ Error] Unit1.cpp(16):E2342 Type mismatch in parameter 'lpEnumFunc'(wanted 'int(__stdcall *)()', got 'int (__stdcall *)(void *,long)')
: 해결좀 해주세요
|