Click here to Skip to main content
16,013,918 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Access Rights! Pin
Tomasz Sowinski4-Apr-02 6:29
Tomasz Sowinski4-Apr-02 6:29 
GeneralRe: Access Rights! Pin
hph4-Apr-02 6:33
hph4-Apr-02 6:33 
GeneralRe: Access Rights! Pin
Tomasz Sowinski4-Apr-02 6:37
Tomasz Sowinski4-Apr-02 6:37 
GeneralRe: Access Rights! Pin
hph4-Apr-02 6:44
hph4-Apr-02 6:44 
GeneralRe: Access Rights! Pin
Tomasz Sowinski4-Apr-02 6:55
Tomasz Sowinski4-Apr-02 6:55 
GeneralRe: Access Rights! Pin
hph4-Apr-02 7:30
hph4-Apr-02 7:30 
GeneralRe: Access Rights! Pin
hph4-Apr-02 9:20
hph4-Apr-02 9:20 
QuestionFunction _beginthreadex not recognized? Pin
NicholasCougar3-Apr-02 21:38
NicholasCougar3-Apr-02 21:38 
I can't fix the problem for two days.
Any help will be greatly appreciated!!!

I created a new project, chose Win32 Application and checked An empty project. Then Added new cpp file and filled in following codes. The debug result has puzzled me for a long time, for there is no hint at all!!!

Here we go...

#define _WIN32_WINNT 0x0500

#define WIN32_LEAN_AND_MEAN

#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <windows.h>

#include <string.h>
#include "..\MtVerify.h"

extern "C"

unsigned WINAPI ThreadFunc(void * p);

HANDLE ghEvent;


#define WM_JOB_PRINT_AS_IS WM_APP + 0x0001
#define WM_JOB_PRINT_REVERSE WM_APP + 0x0002
#define WM_JOB_PRINT_LOWER WM_APP + 0x0003

int main(VOID)
{
HANDLE hThread;
unsigned tid;

ghEvent = CreateEvent(NULL, TRUE, FALSE, NULL);


hThread = (HANDLE) _beginthreadex(NULL,
0,
ThreadFunc,
0,
0,
&tid);
MTVERIFY(hThread);

WaitForSingleObject(ghEvent, INFINITE);

char *szText = strdup("Thank you for buying this book .\n ");
PostThreadMessage(tid, WM_JOB_PRINT_AS_IS, NULL, (LPARAM)szText);

szText = strdup("Text is easier to read forward. \n");
PostThreadMessage(tid, WM_JOB_PRINT_REVERSE, NULL, (LPARAM)szText);

szText = strdup("\nLOWER CASE IS FOR WHISPERING. \n");
PostThreadMessage(tid, WM_JOB_PRINT_LOWER, NULL, (LPARAM)szText);

WaitForSingleObject(hThread, INFINITE);

CloseHandle(hThread);

return 0;
}




VOID CALLBACK TimerFunc(
HWND hwnd,
UINT Msg,
UINT idEvent,
DWORD dwTime)
{
UNREFERENCED_PARAMETER(hwnd);
UNREFERENCED_PARAMETER(&Msg);

PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0,0);

}

unsigned WINAPI ThreadFunc(LPVOID n)
{
UNREFERENCED_PARAMETER(n);


MSG msg;


PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);

SetEvent(ghEvent);

SetTimer(NULL, NULL, 2000, (TIMERPROC) TimerFunc);


while(GetMessage(&msg, NULL, 0,0))
{
char *psz= (char *) msg.lParam;
switch(msg.message)
{
case WM_JOB_PRINT_AS_IS:
printf(" the job print as is called %s", psz);
free(psz);
break;
case WM_JOB_PRINT_REVERSE:
printf(" %s ", strrev(psz));
free(psz);
break;
case WM_JOB_PRINT_LOWER:
printf("%s", _strlwr(psz));
free(psz);
break;
default:
DispatchMessage(&msg);
}
}

return 0;

}

Debug result:

--------------------Configuration: www - Win32 Debug--------------------
Compiling...
worker.cpp
J:\MultiThreads\www\worker.cpp(33) : error C2065: '_beginthreadex' : undeclared identifier
Error executing cl.exe.

www.exe - 1 error(s), 0 warning(s)

Best regard.
AnswerRe: Function _beginthreadex not recognized? Pin
Joaquín M López Muñoz3-Apr-02 21:58
Joaquín M López Muñoz3-Apr-02 21:58 
AnswerRe: Function _beginthreadex not recognized? Pin
Tim Smith4-Apr-02 2:06
Tim Smith4-Apr-02 2:06 
AnswerRe: Function _beginthreadex not recognized? Pin
Le centriste4-Apr-02 5:46
Le centriste4-Apr-02 5:46 
GeneralRe: Function _beginthreadex not recognized? Pin
NicholasCougar4-Apr-02 14:39
NicholasCougar4-Apr-02 14:39 
GeneralRe: Function _beginthreadex not recognized? Pin
Tim Smith4-Apr-02 14:59
Tim Smith4-Apr-02 14:59 
GeneralRe: Function _beginthreadex not recognized? Pin
NicholasCougar4-Apr-02 15:38
NicholasCougar4-Apr-02 15:38 
GeneralCTime !!!! Pin
3-Apr-02 21:36
suss3-Apr-02 21:36 
GeneralRe: CTime !!!! Pin
Michael P Butler3-Apr-02 23:29
Michael P Butler3-Apr-02 23:29 
GeneralRe: CTime !!!! Pin
4-Apr-02 0:28
suss4-Apr-02 0:28 
QuestionThe full path of WordPad.exe ?? Pin
3-Apr-02 21:26
suss3-Apr-02 21:26 
AnswerRe: The full path of WordPad.exe ?? Pin
3-Apr-02 23:05
suss3-Apr-02 23:05 
GeneralRintime error! Pin
Mazdak3-Apr-02 21:09
Mazdak3-Apr-02 21:09 
GeneralRe: Rintime error! Pin
Niklas L3-Apr-02 22:02
Niklas L3-Apr-02 22:02 
GeneralRe: Rintime error! Pin
Mazdak3-Apr-02 22:23
Mazdak3-Apr-02 22:23 
GeneralStatusbar between titlebar and menu Pin
CSZX3-Apr-02 20:12
CSZX3-Apr-02 20:12 
Generalstruct alignment and OSVERSIONINFO Pin
3-Apr-02 19:43
suss3-Apr-02 19:43 
GeneralRe: struct alignment and OSVERSIONINFO Pin
Paul M Watt3-Apr-02 20:33
mentorPaul M Watt3-Apr-02 20:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.