|
When I use AfxBeginThread in a Win32 application, I get this error:
error C3861: 'AfxBeginThread': identifier not found, even with argument-dependent lookup
Not found? When I type AfxBeginThread and then the ( , it lists the parameters for it. Any idea why it is doing this? Any help is appreciated.
-Dev578
|
|
|
|
|
AfxBeginThread is an MFC function. The function essentially wraps up the old C++ _beginthreadex function. If you're only using plain old Win32, you'll need to use this function instead.
Joel Holdsworth
|
|
|
|
|
In addition to Joel's answer, you should also select for 'multi-threaded DLL' in the 'code generation' section of the project's C/C++ properties.
Software Zen: delete this;
|
|
|
|
|
If you are using MFC, have you included afxmt.h in your stdafx.h file?
Joel Holdsworth
|
|
|
|
|
I am trying to create the thread inside a class:
class ThreadClass
{
public:
//...
bool StartThread();
DWORD WINAPI ThreadFunc( LPVOID lpParam );
//...
};
bool ThreadClass::StartThread()
{
DWORD dwThreadId, dwThrdParam = 1;
HANDLE hThread;
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadFunc, // thread function
&dwThrdParam, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
return true;
}
DWORD WINAPI ThreadClass::ThreadFunc( LPVOID lpParam )
{
//do whatever here
return 0;
}
this produces this error:
error C2664: 'CreateThread' : cannot convert parameter 3 from 'DWORD (LPVOID)' to 'LPTHREAD_START_ROUTINE'
Any ideas why it is doing this / how to fix it? Any help is appreciated.
-Dev578
|
|
|
|
|
Make ThreadFunc a static function.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi,
I'm an absolute beginner, started learning C++ a while ago. I'm looking for help to make an application that is able to hide winstyles on all windows and break the MDI of existing applications like Photoshop.
If it's not a big request i would ask for schematic code/ideas.
In depth (only speculation, i've no clue where to start):
1. I would like to hide windowborders, scrollbars and other styles on ALL windows (Windows Classic look) because it's not possible by default in Windows (there's no 0 value for the windowborder in display properties/appearance).
AFAIK it would work with a SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_BORDER); and a dll that intercepts window creation msgs. Somebody suggested WH_CBT hook inside the dll.
There are huge stones in the way. It doesn't work without a system-wide hook and there are several other problems with it. For instance WS_BORDER removes the caption too.. I don't want to remove the caption but the whole windowborder. Or WS_THICKFRAME? I don't know.
2. I would like to break the Multiple Document interface of existing applications (like Photoshop).
There is the well-known mIRC. There you can set MDI childs onto the desktop. Speculating: with a system-wide hook, + SetWindowLong(), SetParent() would allow this. But this way the childwindows would loose all contact with their parent application, is it true?
3. My last question is insignificant but i give it a try. I know some facts about why it's not possible to use 32bit PNGs or BMPs (24bit+alpha channel) on WinXP Visual Styles. GDI is XRGB.
But are there any small chances to break this rule? Like AlphaImageFilter script for Internet Explorer. Or.... I dunno.
Excuse me for the n00b/lame questions.
Thanks in advance,
on
|
|
|
|
|
How can I emulate Ctrl+Ins or Shift+Ins (Ctrl+C Ctrl+V) key combinations. I've seen it in one program where it was possible to define your own keys to work with clipboard. How is it implemented?
|
|
|
|
|
You just need to handle the KEY_UP or KEY_DOWN events in your application and then access the clipboard with whichever key combination you want.
store your internet favourites online - www.my-faves.co.uk
|
|
|
|
|
You must have misunderstood me. The thing I want to do is for example I press Ctrl+Shift+P and text from the clipboard appears on the screen (in Edit Box, Notepad, Word, whatever has the focus). And vice versa I pick out some text with the mouse or keyboard press Ctrl+Shift+C and the text saves to clipboard. That's what I want.
|
|
|
|
|
I'm looking for a lightweight reader/writer for XML files (C++)
Requirements:
- links statically
- does not barf on invalid input (detect is ok), but does not need to verify it
I need to serialize a not too complex dat structure.
Any recommendations?
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
peterchen wrote:
Any recommendations?
Search for pugxml here at CP. Should be just what you want.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
|
Hi,
My purpose is:
- Write a service
- This service must create thread on every process (on every WindowStation)
Problem is:
CreateRemoteThread in MSDN wrote:
Terminal Services isolates each terminal session by design. Therefore,
CreateRemoteThread fails if the target process is in a different session
than the calling process.
If have many users is loging then have many session. I want to
CreateRemoteThread of every session.
My solution is:
- The first, find window station of the process which I must create thread
on it (use WTSEnumerateProcesses)
- The second, use SetProcessWindowStation to assign a window station to the
calling process (is my service). Result my service will operation on the
window station which I must create thread on a process on it.
- Then, use CreateRemoteThread to create thread. Now, CreateRemoteThread is
successful.
Is this solution true ?
Thank in advance.
PTM.
n4_t1
|
|
|
|
|
take a look at this hope it helps
#include "stdafx.h"
#pragma comment(linker,"/base:0x13140000")
DWORD WINAPI inject (void *)
{
MessageBox(0,"a","a",MB_OK);
ExitThread(0);
return 0;
}
void DisplayError(DWORD dwError )
{
LPTSTR lpBuffer = NULL;
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpBuffer, 0, NULL );
if(dwError!=0) MessageBox(GetActiveWindow(), lpBuffer, "Error", MB_OK|MB_ICONERROR);
LocalFree( lpBuffer );
}
bool InjectCode(HANDLE process, LPTHREAD_START_ROUTINE lpCodeToInject)
{
PBYTE nume_exe;
DWORD dimensiune;
LPVOID m2;
nume_exe = (PBYTE)GetModuleHandle(0);
dimensiune = ((PIMAGE_NT_HEADERS)(nume_exe+((PIMAGE_DOS_HEADER)nume_exe)->e_lfanew))->OptionalHeader.SizeOfImage;
VirtualFreeEx(process, nume_exe, 0, MEM_RELEASE);
m2 = VirtualAllocEx(process, nume_exe, dimensiune, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if (!m2) return FALSE;
WriteProcessMemory(process, m2, nume_exe, dimensiune, NULL);
CreateRemoteThread(process, 0, 0, inject, NULL, 0, NULL);
return TRUE;
}
DWORD GetPID(char *szExe)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe32.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hProcessSnap, &pe32))
{
CloseHandle(hProcessSnap);
return 0;
}
do
{
if (lstrcmpi(pe32.szExeFile, szExe) == 0)
{
return (pe32.th32ProcessID);
break;
}
}
while (Process32Next(hProcessSnap, &pe32));
CloseHandle(hProcessSnap);
return 0;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HANDLE hProcess;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetPID("explorer.exe"));
InjectCode(hProcess, inject);
CloseHandle(hProcess);
return 0;
}
gabby
|
|
|
|
|
All,
I'm using a WebBrowser control in my dialog app, and was just wondering if there's some way of removing the border of the control, and in essence getting rid of that sunken look. Ideally I'd like the background of the control to integrate seamlessly with the background of it's parent dialog box, so there's no visual difference between control and dialog.
I think I might have to override the Create() function...
Any help would be appreciated,
Ritcho
|
|
|
|
|
This is supposed to work but doesn't for me. If you find out how please let me know.
HRESULT CDocHostHtmlView::OnGetHostInfo(DOCHOSTUIINFO * pInfo)
{
pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER;
pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
return S_OK;
}
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hi All,
CString csRegHrs;
csRegHrs.Empty();
The next line produces the correct value Say 1000 (for 10.00) in csRegHrs.
csRegHrs = fcvt(m_pDSet->m_REGHRS,2,&decimal,&sign);
Can anyone explain to me why this isn't working.
csRegHrs.Format("%0.2lf");
The above line produces 0.00? Instead it should be 10.00?
I have stepped through the code and when I step into the csRegHrs.Format portion of the code it indicates in red text that it is 0.00 instead of 10.00.
I just don't get it. Any help would be appreciated.
Thanks,
Charlie
Everything is Free Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0
|
|
|
|
|
Charlie Curtis wrote:
Can anyone explain to me why this isn't working.
csRegHrs.Format("%0.2lf");
The above line produces 0.00? Instead it should be 10.00?
Given that the second parameter to Format() is missing, why would you expect it to work?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks for pointing that out. It is usually the simple ones that get you every time... I have put in the second parameter and it is now working fine.
Thanks
Charlie
Everything is Free Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0
|
|
|
|
|
I can't compile the following code:
class Foo
{
public:
template< class T > void F() { T t; }
};
void main()
{
Foo tmp;
tmp.F < bool >();
}
The compile raises the error:
<br />
_samples.cpp(10) : error C2275: 'bool' : illegal use of this type as an expression<br />
_samples.cpp(0) : see declaration of 'bool'<br />
It raises the same error if I replace the bool type by a class.
It works if F is not declared as a member function.
It also works fine like this:
class Foo
{
public:
template<class T> void F(T bool) { T t; }
};
void main()
{
Foo tmp;
tmp.F(true);
}
How to do the call to have this working without having the type in param???
|
|
|
|
|
You have to declare the class as a template class.
template <class T> class foo
{
void F (T var) { cout << var; }
};
void main()
{
bool b = true;
foo<bool> tmp;
tmp.F(b);
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
No, it's not the same purpose.
I really need the template for the member function, not for the class.
It's only for one function, not for the whole class
|
|
|
|
|
class foo
{
template <class T> void F (T var) { cout << var; }
};
void main()
{
bool B = true;
foo Foo;
Foo.F(B);
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Yep, but it's not what I really wanna do
And in this case I prefer doing:
template < class T > void F (T *var) { ... }
and:
Foo.F((bool*)0);
Doing this way, the T object is not construct.
Nonetheless, it's a bit dodgie...
|
|
|
|