|
Hi, i´d like to put and retreive to-from a LPBYTE variable data from a class, like
class A
{
int a;
double b;
LPBYTE GetStream();
} void SetStream(LPBYTE lpData, DWORD dwLen);
...
A class1,class2;
LPBYTE stream = class1.GetStream();
class2.SetStream(stream)
Qhris!
|
|
|
|
|
How does one go about opening a file that is located in the directory of the executable without using any code that is OS-dependent (not microsoft functions)?
(The user could be in a directory different from where the executable is located, and run that executable, which opens a file in the directory where the executable is located.)
Thanks!
|
|
|
|
|
In standard C, I am prertty sure that the argv[0] command line argument to main usually has the full path of the executable file. Strip off the program's file name, you are left with the path to folder where exe is located.
|
|
|
|
|
Okay, "HOW TO: Write an Applciation That Supports Fast User Switching in Windows XP".
Yep, another technically accurate but totally worthless document from Microsoft
Statements like "Block any problematic features' are useless. Well, what could I expect to be problematic? If I blocked the user from switching, the app would work fine.
So, now that I have the session switch notifications in the program and I get WTS_SESSION_LOCK and WTS_SESSION_UNLOCK, what kinds of activity should I PREVENT while the session is locked?
My program is actually returning ACCESS DENIED (GetLastError = 5) on a call to the Rectangle(HDC, int, int, int, int) GDI function!
And of course, they have the classic 'FindWindow' example of locating an existing instance..
Any worthwhile ideas?
|
|
|
|
|
Will UrlDownLoadToFile() works fine when used from a NT Service application running under System account.
As far as i know this function uses IE settings to download URLs. So i am afraid whether Local System account will be able to access IE settings ?
|
|
|
|
|
i am trying to update a record for which i create a new query example:
CDatabase DB;<br />
<br />
<br />
CString sAddress;<br />
sAddress = _T("11 pivot drive st'micheals");<br />
<br />
<br />
CString sSQL<br />
sSQL.Format(_T("Update TableNameHere Set Address='%s'),sAddress);<br />
<br />
DB.Execute(sSQL);
since the string sAddress contains a ' character in it the query wont execute.
do i have to replace ' with \' or is there any other way outta this
thanks
|
|
|
|
|
Modify your routine to escape the ', which consists of doubling them.
Ex:
11 pivot drive st'micheals
becomes
11 pivot drive st''micheals
NOTE: Don't use the " character !
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
I want use Timer in my Service prog,and add this code:
SetTimer(NULL, 0, 1000, Timer2);
Timer2 is a function name in my deifned Class.but when the prog compile,it shows that :error C2664: 'SetTimer' : cannot convert parameter 4 from 'void (struct HWND__ *,unsigned int,unsigned int,unsigned long)' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)'
who can tell me:what is my problem?
class CServiceWnd : public CWinThread
{
void CALLBACK Timer2(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime);
int m_Timer2;
..................
}
void CALLBACK CServiceWnd::Timer2(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{
if(Createsocket())
{
KillTimer(NULL,m_Timer2);
}
}
void CServiceWnd::OnClose()
{
...................
m_Timer2=SetTimer(NULL,0, INTERVAl,Timer2);
}
|
|
|
|
|
Your timer callback function should either be a static member function or a global function. If you want to use a nonstatic member function as a calback then you have to jump through a few hoops. See http://www.codeproject.com/cpp/SoloGenericCallBack.asp[^] for details.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Timer32() should not be a member of the CServiceWnd class. That's why it does not match the required prototype. The this pointer is getting in the way.
One solution would be to pass NULL as the third parameter to SetTimer() , and then provide an OnTimer() function of your CServiceWnd class. From there, you can call CreateSocket() , etc.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I got a program running in multiple processes on the same machine and all of them are writing to the same log file.
I want to make sure that they are not trying to write to the log at the same time.
And need some sort of locking or criticalsection type of thing that works over different processes.
Any one got any tips?
|
|
|
|
|
|
You probably want it to be a named mutex unless your log code is in a common dll and you have declared the mutex in a shared section.
John
|
|
|
|
|
If you are also guarding against multiple USER sessions, you need to be aware of terminal services issues, and also to apply more than 'NONE', EMPTY', or 'NULL DACL' security on the synchronization object or no one else will be able to open it up right all the time.
I am pulling my few remaining hairs out sorting this all out for terminal services and Windows XP Fast User Switching.
|
|
|
|
|
Aside from the mutex, you can open your log file exclusively. I believe the CFile::Open function returns a bool if the file opens, so if your file doesn't open, it means somebody else (another app) is using that file, so just let your app keep trying until it gets access. I wouldn't go trying this on a file where more than a few applications (threads) are going to be using it, but it's a cheap little way of assuring you have exclusive access to your file. However, the code can get a little tricky because you also need to make sure that the file actually exists before you enter a loop that tries to open it exclusively...otherwise your program will go into an infinite loop. The only real benefit of using this method is that you can share your log file on a network, and have your application on multiple computers share it...don't know if you're getting that complex or not (if you are, look into using a database instead.) Good luck
|
|
|
|
|
I'm writing a C++ DLL and am trying to incorporate a call to the FlashWindowEx API. Yet when I compile it errors out that it does not know this API call (error C2065: 'FlashWindowEx' : undeclared identifier). I added the winuser.h file to my code and the user32.lib to my project properties. Still is does not find it.
Has anyone got any suggestions?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
|
Michael
Not sure this pertains to me. As I'm writting this on a laptop that has VS 6.0 and .NET studio with MSDN for .NET 2003 installed on it. Also this app is only intended to run on XP or 2000.
Here is a break down of my app header file:
#ifdef WINSTYLE_EXPORTS<br />
#define WINSTYLE_API __declspec(dllexport)<br />
#else<br />
#define WINSTYLE_API __declspec(dllimport)<br />
#endif<br />
<br />
<br />
<br />
extern WINSTYLE_API char nWinStyle; <br />
WINSTYLE_API int GetCloseWin(char);<br />
WINSTYLE_API int GetOpenWin(char);<br />
WINSTYLE_API int GetCloseApp(char);<br />
WINSTYLE_API int SetWinFocus(char);<br />
WINSTYLE_API int SetWinFocusEx(char);<br />
and my stdafx.h file
<br />
#if !defined(AFX_STDAFX_H__4D8BF925_F169_11D4_8093_0050DA27906F__INCLUDED_)<br />
#define AFX_STDAFX_H__4D8BF925_F169_11D4_8093_0050DA27906F__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
<br />
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers<br />
<br />
#include <windows.h><br />
<br />
<br />
<br />
#endif // !defined(AFX_STDAFX_H__4D8BF925_F169_11D4_8093_0050DA27906F__INCLUDED_)<br />
Do I still need to add the defines even though it will never run on anyhting below W2k?
Thanks for the help.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
Do I still need to add the defines even though it will never run on anyhting below W2k?
Yes, from the FAQ:By default, you can only use functions in Windows 95, NT 3.51, and pre-IE3 common controls. To use APIs introduced in later versions of Windows or the common controls, you need to #define the above symbols correctly before including any Windows headers. To be safe, I always define those symbols no matter what. Some of the headers will override the defaults, for example some headers will have this:
#ifndef _WIN32_IE
#define _WIN32_IE 0x0500
#endif but then you're at the mercy of whoever wrote the header file and what he thought a "good" version was.
Here's what I use:
#define WINVER 0x0500
#define _WIN32_WINDOWS 0x0410
#define _WIN32_WINNT 0x0500
#define _WIN32_IE 0x0501 which enables features in 98+, 2000+, and IE 5+.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
You cannot stop me with paramecium alone!
|
|
|
|
|
I added these define statements before my header files and now I'm down to one error but it's the same one.
One other question. Do I need to add the
Michael Dunn wrote:
#ifndef _WIN32_IE#define _WIN32_IE 0x0500#endif
Statement after the defines statments and insclude all the different defines?
Any other suggestions?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
|
This is really strange. I've added in the defines and it still does not find the function. When I search the winuser.h file for the function is does not exist. It resides in the winuser.h file in the include folder under .NET studio.
According to MSDN is says that it is defined in the winuser.h file and is compatable on 98 on up. If I copy over the file from .NET studio to the VC98 then I get 53 errors.
Has anyone used this function on a regular C++ app before?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi,
I´ve have written an Outlook automation (whith wrapper classes).
After this Outlook crashes sometimes without any known reason.
Outlook starts an dialog where the user can send this report to Microsoft.
What kind of problems could Outlook have after automation ?
Is there a way to find the problem in the report ?
regards, JohnX
|
|
|
|
|
Does anyone know how I can get the VS.Net IDE to show me a list of the available messages for a control that's created dynamically in a view? You know, like you get when you select a control on a dialog or a form in the res editor... It's a pain to code this stuff manually
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Why not place the control on the form in the res editor, write all the code to handle it, then remove the control from the form?
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|