|
How do i get the handle for the first parameter in GetSecurityInfo()!!
|
|
|
|
|
This is the file handle returned by CreateFile.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Have you ever used the function LogonUser() ??
|
|
|
|
|
|
I allways get the error message: ERROR_PRIVILEGE_NOT_HELD. I know what it means, but i don't know how to fix it! What must i do to get i work!
|
|
|
|
|
Check KB article Q180548
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
|
i have taken a look at the documentation you mentioned. It works fine, no warnings or errors at all. But the description of that code says that it can be used in the same way like LogonUser().
But where do i see that i works in the same way ?
and
LogonUser() returns a handle to the logged on user, which can be used in CreateProcessAsUser(). Where can i find or get this handle in that sample code ??
|
|
|
|
|
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.
|
|
|
|
|
You chose the wrong type of app. It should be "Console application" instead of "Win32 application".
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You didn't tell the compiler you were building for multithreaded. Change that in the settings.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
#include <process.h>, unless it is already one of your other includes. Hard to know, since we don't see them.
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Though CodeProject is said the most powerful forum, frankly speaking, I am disappointed.
Codeguru forum answered my question. That site rich in experts IN ANSWERING QUESIONS.
I really hope that CodeProject can adopt some advanced ideas in Codeguru.
The problem is:
_beginthreadex is in MFC. I didn't check the "An Application that supports MFC" in step 1 of Creating "Win32 Console Application" Wizard.
Thanks to all who answered my question.
Best regard.
|
|
|
|
|
1. _beginthreadex is NOT part of MFC. Anybody who told you this doesn't know what they are talking about. If you do a search of the VC include files you will find it defined in process.h. This is part of the CRTL. (Which is TOTALLY different than MFC).
#ifdef _MT
_CRTIMP uintptr_t __cdecl _beginthread (void (__cdecl *) (void *),
unsigned, void *);
_CRTIMP void __cdecl _endthread(void);
_CRTIMP uintptr_t __cdecl _beginthreadex(void *, unsigned,
unsigned (__stdcall *) (void *), void *, unsigned, unsigned *);
_CRTIMP void __cdecl _endthreadex(unsigned);
#endif
2. If you are including process.h and still are not getting _beginthreadex, then _MT is not being defined. This is AUTOMATICALLY defined when you build the program for multithreaded operations.
The only reason changing MFC settings would have caused your program to build is that it has also modified your compiler options to build for multithreaded operations.
This is EXACTLY the information we gave you.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Ok, let's put it clear and clean.
I've chosen "Win32 Console Application" and then checked "An Empty Application". My application itself is a single thread. Though I set the "Use Runtime Library" as "Multithreads". The debug results are:
--------------------Configuration: Worker - Win32 Debug---------------
Compiling...
worker.cpp
Linking...
LIBCMT.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Worker.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Worker.exe - 2 error(s), 0 warning(s)
Somebody said that I'd used the wrong console. I used "Win32 Console Application", and in "An simple application", the app is just as:
// worker09.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main(int argc, char* argv[])
{
return 0;
}
There is no such thing like "WinMain()".
There are somethings in your comment, but the problem is still out there.
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. A quetion can make one somebody if he takes it really seriously.
One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
Why CTime Appel(1970,1,1,0,0,0); create a failed insertion???
|
|
|
|
|
What exactly is the problem?
I tried your code in VC6 SP5 (Windows 2000) and it worked okay. What version of compiler are you using?
Michael
|
|
|
|
|
|
Hi, folks,
I got a question about getting the full path of WordPad.exe.
How can I get the full path of WordPad.exe ?
I mean, some system uses something like this:
C:\\Program Files\\Accessories\\WordPad.exe
while on Windows XP, it might be:
C:\\Program Files\\Windows NT\\Accessories\\WordPad.exe
So, any one help me ?
And, I want to paunch WordPad.exe and open my document (something like *.txt
or *.doc), I use CreateProcess to do this, but, WordPad.exe is launched, but my document is NOT opened ?
CreateProcess( "C:\\Program Files\\Accessories\\WordPad.exe", "D:\\myDoc.txt", NULL, NULL,FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo ))
Could any one tell me what's the right way to open my document with wordpad.exe ?
Any response would be appreciated. Thanks in advance !
|
|
|
|
|
you can find the path of wordpad in the registry by getting the key in the run keys
|
|
|
|
|
I use this code in a 'while' loop:
FILE *afile;
int numwritten;
afile = fopen( strpath, "r+" );
char list1[1];
list1[0] = (char)('a');
list1[1] = (char)('a');
numwritten = fwrite( list1 , sizeof( char ), 1, afile );
It does what I want but after while loop ends this runtime error occur:
Run-Time Check Failure #2 - Stack around the variable 'list1' was corrupted.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
You are only allocating one character, while accessing two. Use:
char list1[2];
You will also need to close the file after writing to it.
|
|
|
|
|
Niklas Lindquist wrote:
You are only allocating one character, while accessing two. Use:
Yes,that was the problem.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
My problem is that I want to place the statusbar between the the titlebar and the menu.
Please, help me!!!!
CSZX
|
|
|
|
|
Struct aligment is decided at compile-time. Fine.
But some functions, like GetVersionEx and IContextMenu::InvokeCommand uses the size member of the input structure to decide which struct is passed. They must check if the cbSize member is set to sizeof(...). Since that code is compiled by ms, they might have different struct aligment settings => different return value from sizeof. How does this work? Isn't there a potential bug somewhere?
A second example. Check the structure FILEGROUPDESCIPTOR. It has a serie of FILEDESCRIPTOR structures as members. How can one be convinced that my code and the ole libraries agrees on where each struct starts?
|
|
|
|
|