|
I got some weird bug on my system where it keeps doing a reboot (not BSOD). Is there a way to track which process is calling InitiateSystemShutdown?
This is weird. I found this in Event Viewer
The process winlogon.exe has initiated the restart of WS-176 for the following reason: No title for this reason could be found
Minor Reason: 0xff
Shutdown Type: reboot
Comment:
Todd Smith
|
|
|
|
|
|
Right click on the solution name or sub-project name in the Solution Explorer and select 'Rename'.
Or, select the desired item and change it's name in the property window.
Nick
This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2002 Microsoft Corporation. All rights reserved.
|
|
|
|
|
First, I have read all the post concerning plugins. Most tell you to use COM. So lets start with NO COM. Please. I have 3 functions I want to support dlls in. They are all simple functions, pass data, get data back. I only need one dll per function to be loaded at a time. The dll's will need to register themselves on install, and the user can select what dll they want to use. What is the simplest way to do this. I was once told that as long as you keep the same functions exported in each dll, same input/output data types, that all you need to do is to load whatever dll you want. Please confirm this. OK I will digress to keep this from getting to long. Please help.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
Darroll wrote:
I was once told that as long as you keep the same functions exported in each dll, same input/output data types, that all you need to do is to load whatever dll you want
Yes. Use LoadLibrary with correct path, then GetProcAddress with function name.
Of course, there's number of things to remember - for example, if you're linking statically with CRT, then your dll shouldn't free blocks allocated in exe and vice versa.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
Darroll wrote:
I was once told that as long as you keep the same functions exported in each dll, same input/output data types, that all you need to do is to load whatever dll you want.
Yes, that's right. You can load the DLL chosen at runtime using LoadLibrary. Instead of registering the DLLs, I scan a program directory for DLLs at startup using Version Info resource to sort the DLLs by categories.
Example:
typedef int (CALLBACK* LPDLLMYFUNC)(char *data);
...
HINSTANCE hDLL = LoadLibrary(dllpath);
int res;
char data[] = "bflmpsvz";
if (hDLL != NULL)
{
LPDLLMYFUNC lpfnDllFunc = (LPDLLMYFUNC)GetProcAddress(hDLL,"MyFunc");
if (lpfnDllFunc)
{
res = lpfnDllFunc(data);
}
FreeLibrary(hDLL);
}
You need to export the function int MyFunc(char *data) from your DLL.
Pavel
Sonork 100.15206
|
|
|
|
|
I am currently writing an MFC extension DLL to handle plug-ins. It should hopefully be finished some time in the next few weeks. It will have all the bells n whistles, but it sounds like you need a very small sub-set of options. Th best bet would be to write a DLL wrapper class which can be passed a filename of a DLL, loads it, gets all the function pointers and such and allows you to call from it. As an example, here is some of the code from my library that does this. It may be of help.
#ifndef CDLLwrapper_included
#define CDLLwrapper_included 1
class CMyMultiDocTemplate ;
typedef int (* GETDOCUMENTTEMPLATECOUNT)() ;
typedef CMyMultiDocTemplate* (* GETDOCTEMPLATE)(int index) ;
typedef void (* INITIALISEDLL)(CWinApp *pApp) ;
typedef void (* RELEASEDLL)() ;
typedef AFX_MSGMAP* (* GETPREMESSAGEMAP)(LPCTSTR pClassname) ;
typedef AFX_MSGMAP* (* GETPOSTMESSAGEMAP)(LPCTSTR pClassname) ;
class _PLUGIN_API CDLLWrapper
{
public:
CDLLWrapper() ;
CDLLWrapper(CString& filename) ;
CDLLWrapper(CDLLWrapper& other) ;
virtual ~CDLLWrapper() ;
bool LoadDLL(CString filename) ;
bool FreeDLL() ;
CDLLWrapper& operator=(CDLLWrapper& other) ;
void InitialiseDLL(CWinApp *pApp) ;
void ReleaseDLL() ;
int GetDocTemplateCount() ;
CMyMultiDocTemplate* GetDocTemplate(int index) ;
AFX_MSGMAP* GetPreMessageMap(LPCTSTR pClassName) ;
AFX_MSGMAP* GetPostMessageMap(LPCTSTR pClassName) ;
private:
CString m_filename;
HINSTANCE m_DLLhInstance ;
INITIALISEDLL m_pFNInitialiseDLL ;
RELEASEDLL m_pFNReleaseDLL ;
GETDOCUMENTTEMPLATECOUNT m_pFNGetDocTemplateCount ;
GETDOCTEMPLATE m_pFNGetDocTemplate ;
GETPREMESSAGEMAP m_pFNGetPreMessageMap ;
GETPOSTMESSAGEMAP m_pFNGetPostMessageMap ;
} ;
#endif // CDLLwrapper_included
#include "stdafx.h"
#include "DLLwrapper.h"
#include "MyMultiDocTemplate.h"
CDLLWrapper::CDLLWrapper()
{
m_DLLhInstance = NULL ;
m_filename = "" ;
m_pFNGetDocTemplateCount = NULL ;
m_pFNGetDocTemplate = NULL ;
m_pFNInitialiseDLL = NULL ;
m_pFNReleaseDLL = NULL ;
m_pFNGetPreMessageMap = NULL ;
m_pFNGetPostMessageMap = NULL ;
}
CDLLWrapper::CDLLWrapper(CDLLWrapper& other)
{
*this = other ;
}
CDLLWrapper::~CDLLWrapper()
{
FreeDLL() ;
}
bool CDLLWrapper::LoadDLL(CString filename)
{
m_filename = filename ;
m_DLLhInstance = LoadLibrary(filename) ;
if (m_DLLhInstance != NULL)
{
m_pFNGetDocTemplateCount = (GETDOCUMENTTEMPLATECOUNT)GetProcAddress(m_DLLhInstance, "GetDLLDocTemplateCount") ;
m_pFNGetDocTemplate = (GETDOCTEMPLATE)GetProcAddress(m_DLLhInstance, "GetDLLDocTemplate") ;
m_pFNInitialiseDLL = (INITIALISEDLL)GetProcAddress(m_DLLhInstance, "InitialiseDLL") ;
m_pFNReleaseDLL = (RELEASEDLL)GetProcAddress(m_DLLhInstance, "ReleaseDLL") ;
m_pFNGetPreMessageMap = (GETPREMESSAGEMAP)GetProcAddress(m_DLLhInstance, "GetPreMessageMap") ;
m_pFNGetPostMessageMap = (GETPOSTMESSAGEMAP)GetProcAddress(m_DLLhInstance, "GetPostMessageMap") ;
}
return (m_DLLhInstance != NULL) ;
}
bool CDLLWrapper::FreeDLL()
{
if (m_DLLhInstance != NULL)
{
FreeLibrary(m_DLLhInstance) ;
m_DLLhInstance = NULL ;
m_filename = "" ;
m_pFNGetDocTemplateCount = NULL ;
m_pFNGetDocTemplate = NULL ;
m_pFNInitialiseDLL = NULL ;
m_pFNReleaseDLL = NULL ;
m_pFNGetPreMessageMap = NULL ;
m_pFNGetPostMessageMap = NULL ;
}
return true ;
}
CDLLWrapper& CDLLWrapper::operator=(CDLLWrapper& other)
{
FreeDLL() ;
m_filename = other.m_filename ; other.m_filename = "" ;
m_DLLhInstance = other.m_DLLhInstance ; other.m_DLLhInstance = NULL ;
m_pFNGetDocTemplateCount = other.m_pFNGetDocTemplateCount ; other.m_pFNGetDocTemplateCount = NULL ;
m_pFNGetDocTemplate = other.m_pFNGetDocTemplate ; other.m_pFNGetDocTemplate = NULL ;
m_pFNInitialiseDLL = other.m_pFNInitialiseDLL ; other.m_pFNInitialiseDLL = NULL ;
m_pFNReleaseDLL = other.m_pFNReleaseDLL ; other.m_pFNReleaseDLL = NULL ;
m_pFNGetPreMessageMap = other.m_pFNGetPreMessageMap ; other.m_pFNGetPreMessageMap = NULL ;
m_pFNGetPostMessageMap = other.m_pFNGetPostMessageMap ; other.m_pFNGetPostMessageMap = NULL ;
return *this ;
}
void CDLLWrapper::InitialiseDLL(CWinApp *pApp)
{
if (m_pFNInitialiseDLL != NULL)
{
m_pFNInitialiseDLL(pApp) ;
}
}
void CDLLWrapper::ReleaseDLL()
{
if (m_pFNReleaseDLL)
{
m_pFNReleaseDLL() ;
}
}
int CDLLWrapper::GetDocTemplateCount()
{
if (m_pFNGetDocTemplateCount)
{
return m_pFNGetDocTemplateCount() ;
}
return 0 ;
}
CMyMultiDocTemplate* CDLLWrapper::GetDocTemplate(int index)
{
if (m_pFNGetDocTemplate)
{
ASSERT(index >= 0) ;
ASSERT(index < GetDocTemplateCount()) ;
return m_pFNGetDocTemplate(index) ;
}
return NULL ;
}
AFX_MSGMAP* CDLLWrapper::GetPreMessageMap(LPCTSTR pClassName)
{
if (m_pFNGetPreMessageMap)
{
return m_pFNGetPreMessageMap(pClassName) ;
}
return NULL ;
}
AFX_MSGMAP* CDLLWrapper::GetPostMessageMap(LPCTSTR pClassName)
{
if (m_pFNGetPostMessageMap)
{
return m_pFNGetPostMessageMap(pClassName) ;
}
return NULL ;
}
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Wow, please keep me in mind when you release this. My Email is darrollwalsh@hotmail.com. Send me a copy when you post it. I was only keeping it simple because of my lack of knowlade in using plugins. I think I will be able to expand my app when you let this baby out. Just add how to add it to an existing DLG app. Thatnk in advance.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
i've put an HWND created by IShellView:CreateViewWindow in a CView. when i resize the window, the display is broken, especially when i set the view to DETAILS, and resize the windows horizontally : the display of the right-hand scrollbar is broken.
you can easily try it by creating an MFC appwizard project, SDI, and use CHtmlView as base class for the view class. in the view .cpp file, change the line :
Navigate2(_T("http://www.microsoft.com/visualc/"),NULL,NULL);
to :
Navigate2(_T("c:\\"),NULL,NULL);
you won't even have to set to DETAILS mode, just resize the window horizontally and you'll see right-hand scrollbar won't be displayed correctly.
how to correct this ? (no one will have the answer i'll bet)
|
|
|
|
|
I've had a similar problem with another activeX control, the scrolbar disapears when you resize.
I added
::RedrawWindow('HWND OF YOUR WINDOW',NULL,NULL,RDW_FRAME |RDW_ERASE|RDW_INVALIDATE|RDW_ALLCHILDREN );
After the MoveWindow function, it seemed to get it alright.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
thank you very much.
i've also added your line in the OnDraw function because i also got the problem when the application starts...
|
|
|
|
|
Anyone has any idea how to initialize a listbox with file names matching a given criterion? I'd like the listbox to display all .txt files in a directory. Thanks,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
|
Because it doesnt work! I am suspecting that maybe I dont have the right parent for a control on a CFormView form.
THe SendMessage API is being called with handles obtained from:
CMDIFrameWnd *pFrame =
(CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild =
(CMDIChildWnd *) pFrame->GetActiveFrame();
CProgressBarCZipView *pView = (CProgressBarCZipView *) pChild->GetActiveView();
long parentHandle = (long)pView->GetSafeHwnd();
CButton *pBar = (CButton*)GetDlgItem(IDC_BUTTON3);
long hPbHandle = (long)pBar->GetSafeHwnd();
_CllRemoteCall p;
p.CreateDispatch("DllwithForm.Class1");
p.TestButton(hPbHandle,parentHandle);
This call suposedly causes the SendMessage to execute (or not !)
SendMessage(parentHAndle, WM_COMMAND, 0, buttonHandle)
but I'm still doing something wrong.
Any ideas ?
Thanks,
ns
|
|
|
|
|
wParam (3rd arg) in SendMessage call should be the button ID, not the button handle. It should look more or less like this:
SendMessage(parentHandle, WM_COMMAND, IDC_BUTTON3, 0);
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
It didnt like the ordering of the parameters and crashed. I found from MSDN:
WM_COMMAND
The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.
A window receives this message through its WindowProc function.
LRESULT CALLBACK WindowProc(
HWND hwnd,
WM_COMMAND,
WPARAM wParam,
LPARAM lParam
);
so I did
SendMessage(parentHAndle, WM_COMMAND, 0, buttonHandle)
Doesnt crash now, but alas my poor lowly button remains untriggered(I havent graduated to your idea of custom messages yet )
I fear its maybe time to look into shared memory, which is not going to be easy.
If only the sendmessage worked...BTW I also tried sending in the ID of the button instead of the handle so that the SendMessage could use it, but still not.
You have really put a lot of time into my problem and I want to say that I appreciate it very much.
Thanks,
ns
|
|
|
|
|
Try with both ID and handle:
SendMessage(parentHandle, WM_COMMAND, ID_BUTTON, buttonHandle);
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
That made it very unhappy....crashed grandly.
Thanks,
ns
|
|
|
|
|
Try this:
<br />
SendMessage(parentHandle, WM_COMMAND, MAKELONG( IDC_BUTTON3, BN_CLICKED ), buttonHandle );<br />
Chris Richardson
|
|
|
|
|
Does anyone here have an example of a User Interface library for AD Schema modifications?
I am working on some additional attributes for a user and need to place a new tab in the properties window (like Exchange does) so the admin has a way to set the properties.
|
|
|
|
|
I am trying to get to get a tree conrol to place the text that it selects at the very top of its corresponding view. I have tried the following code (as is, and with adding/subtracting a value to it) and the result is always that the highlighted text is 1 line above the visible line. Without the LineScroll code, then the selection (highlight) may/may not appear within the visible view, depending upon the direction of the next line.
sSecondPart = sItemData.Right(sItemData.GetLength()-sFirstPart.GetLength());
CMainFrame* pMDIFrame = (CMainFrame*)AfxGetMainWnd();
ASSERT(pMDIFrame);
CChildFrame* pMDIChild = (CChildFrame*)pMDIFrame->MDIGetActive();
ASSERT(pMDIChild);
CEJOrganizerView* pView = (CEJOrganizerView*) pMDIChild->m_wndSplitter.GetPane(0,1);
CRichEditCtrl& rCtrl = pView->GetRichEditCtrl();
int iStart = rCtrl.LineIndex(atoi(sSecondPart));
int iEnd = rCtrl.LineIndex(atoi(sSecondPart)+1);
int iFirstVisible = rCtrl.GetFirstVisibleLine();
// This doesn't work as intended,
rCtrl.LineScroll(rCtrl.LineIndex(atoi(sSecondPart)) - iFirstVisible,0);
rCtrl.SetSel(iStart,iEnd);
if I use: rCtrl.LineScroll(-iFirstVisible,0) then the selected text is always in view, but it is always toward the bottom of the view.
Thanks
Wade Holt
|
|
|
|
|
Ok, so how do I get from:
double x = .0625;
CString s;
s.Format("???",x);
so that s looks like: 6.25000000000000000E-02
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
s.Format("%.16E",x) - i think...
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
|
Try this:
double fp = .0625;<br />
CString s;<br />
s.Format( "%e", fp );
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|