|
Dear all:
I use winIo.dll with my project, when I call InstallWinIoDriver function, it always return false, but my application still work,
What happened? There are source code below
bool _stdcall InstallWinIoDriver(PWSTR pszWinIoDriverPath, bool IsDemandLoaded)
{
SC_HANDLE hSCManager;
SC_HANDLE hService;
RemoveWinIoDriver();
hSCManager = OpenSCManager(NULL, NULL,
SC_MANAGER_ALL_ACCESS);
if(hSCManager)
{
hService = CreateService(hSCManager, L"WINIO", L"WINIO",
SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, (IsDemandLoaded
== true) ? SERVICE_DEMAND_START : SERVICE_SYSTEM_START,
SERVICE_ERROR_NORMAL, pszWinIoDriverPath, NULL, NULL, NULL,
NULL, NULL);
CloseServiceHandle(hSCManager);
if(hService == NULL)
return false; }
else
return false; CloseServiceHandle(hService); return true; }
Thanks for your help, Victor
|
|
|
|
|
I have no idea really. But it's always useful to have some trace-code that prints the result of GetLastError() and FormatMessage() . Something like:
<br />
<small>MY_TRACE (("CreateService() failed; %s\n", my_strerror(GetLastError())));</small><br />
-- Gisle V.
|
|
|
|
|
Hmmm,
Could be that the CreateService function[^] is returning either ERROR_DUPLICATE_SERVICE_NAME or maybe ERROR_SERVICE_EXISTS.
As previously stated GetLastError[^] is your friend.
cedricvictor wrote: but my application still work,
Keep in mind that if you do not have source code for winIo.dll ... it could also be installing the service.
Best Wishes,
-David Delaune
|
|
|
|
|
Dear Randor:
You are right. In other function, the service is exist.
So the function always return false.
Thank for your help, Victor
|
|
|
|
|
Hi friends & Gurus,
May i know is visual c++ 6 is free downloadable / freeware ?
Please update me the details.
Thanks & Regards,
TV Krishna Rayalu
|
|
|
|
|
It is neither freeware nor downlodable.
Veni, vidi, vici.
|
|
|
|
|
Thank you. But VB 6 is freeware it seems. correct me if iam wrong.
|
|
|
|
|
As far as I know VB6 is NOT free.
Veni, vidi, vici.
|
|
|
|
|
VC6 is not free. There were special versions for publication on media of C/C++ books. So you might get such a book to get the special VC6 version for non-commercial purposes (compiled programs will show a message at each start).
But VC 6 is outdated. There is no reason to use it anymore.
If you are looking for a free Visual Studio version, you can download the Express versions from Microsoft at http://www.visualstudio.com/downloads/download-visual-studio-vs[^].
|
|
|
|
|
Thank you Jochen, i need it for commercial purpose. It is for very old Visualstudio 6 project maintenence purpose i required vc++6.
|
|
|
|
|
If you don't want to convert the project to a newer VC version (which may be difficult), you can look for a used version. But note that those may not include the latest service packs (SP5 from 2003 and SP6 from 2004).
|
|
|
|
|
Thanks for the precautions i need to take , if it need to be upgrade.
But as of now it is just support work.
|
|
|
|
|
When I've had to use really old versions of something... I've gone to ebay and looked there. The other way would be if you have an MSDN subscription, since MS usually makes all versions of their IDEs available to developers to download through there, but a subscription is pricey to begin with (you'll likely find it cheaper through some third party online).
|
|
|
|
|
In OnTimer, I write a test program. if I don't use CreateCompatibleDC(), It works well, otherwise, no display.
Please help me to find the reason.
void CDynamicShowTextDlg::OnTimer(UINT nIDEvent)
{
CDC *pDC;
CRect tRect;
CDC MemDC;
pDC = this->GetDC();
GetClientRect(&tRect);
MemDC.CreateCompatibleDC(NULL);
MemDC.SetBkMode(TRANSPARENT);
if (test == 0 ){
MemDC.SetTextColor(RGB(255,255,255));
MemDC.DrawText(_T("My Test"),&tRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
MemDC.SetTextColor(RGB(255,0,0));
MemDC.DrawText(_T("TEST"),&tRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}
else {
MemDC.SetTextColor(RGB(255,255,255));
MemDC.DrawText(_T("TEST"),&tRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
MemDC.SetTextColor(RGB(0,150,0));
MemDC.DrawText(_T("My Test"),&tRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}
m_Seconds++;
m_TimerEcho.Format(_T("%d: Seconds have passed"), m_Seconds);
test ^= 1;
MemDC.DeleteDC();
ReleaseDC(pDC);
UpdateData(FALSE);
}
with pDC, it works well.
modified 17-Mar-14 11:40am.
|
|
|
|
|
You can see drawing operations occurred into a memory device context only if you BitBlt it to a 'standard' device context (see, for instance "CDC::CreateCompatibleDC" at MSDN[^].
Veni, vidi, vici.
|
|
|
|
|
I added a statement:
int nX = tRect.left + tRect.Width() / 2;
int nY = tRect.top + tRect.Height() / 2;
pDC->BitBlt(nX, nY, tRect.Width()/3, tRect.Height()/3, &MemDC,
0, 0, SRCCOPY);
But still get nothing on the screen.
|
|
|
|
|
you need to create a bitmap for your memdc to draw on.
see MSDN dox for CDC::CreateCompatibleDC:
http://msdn.microsoft.com/en-us/library/kwxzck32.aspx[^]
from the dox:
When a memory device context is created, GDI automatically selects a 1-by-1 monochrome stock bitmap for it. GDI output functions can be used with a memory device context only if a bitmap has been created and selected into that context.
|
|
|
|
|
Thanks, now the test string appeared.
But, the client area is black, and show text string in while color only, no change.
Please refer to the code:
void CDrawTextTstDlg::OnTimer(UINT_PTR nIDEvent)
{
CDC *pDC;
CRect tRect;
CDC MemDC;
pDC = this->GetDC();
GetClientRect(&tRect);
MemDC.CreateCompatibleDC(NULL);
CBitmap bmp;
bmp.CreateCompatibleBitmap(&MemDC, tRect.Width(), tRect.Height());
CBitmap *oldBitmap = MemDC.SelectObject(&bmp);
MemDC.SetBkMode(TRANSPARENT);
if (gtest == 0 ){
MemDC.SetTextColor(RGB(255,255,255));
MemDC.DrawText(_T("My Test"),&tRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
MemDC.SetTextColor(RGB(255,0,0));
MemDC.DrawText(_T("TEST"),&tRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}
else {
MemDC.SetTextColor(RGB(255,255,255));
MemDC.DrawText(_T("TEST"),&tRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
MemDC.SetTextColor(RGB(0,150,0));
MemDC.DrawText(_T("My Test"),&tRect,DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}
pDC->BitBlt(0, 0, tRect.Width(), tRect.Height(), &MemDC,
0, 0, SRCCOPY);
m_Seconds++;
m_TimerEcho.Format(_T("%d: Seconds have passed"), m_Seconds);
gtest ^= 1;
MemDC.SelectObject(oldBitmap);
bmp.DeleteObject();
MemDC.DeleteDC();
ReleaseDC(pDC);
CDialog::OnTimer(nIDEvent);
}
|
|
|
|
|
bmp.CreateCompatibleBitmap(&MemDC, tRect.Width(), tRect.Height());
instead of MemDC there, use the DC that you used as the source for CreateCompatibleDC.
when a memory DC is created, it has a 1x1 pixel monochrome bitmap selected into it. if you create a bitmap compatible with that, you'll get a monochrome bitmap.
also, if you want a background color, you'll need to fill the bitmap with that color (CDC::FillSolidRect)
|
|
|
|
|
Thank you very much.
Now I can see the Text string color is changing.
While, the whole dialog screen is black too, some controls, static texts all disappeared.
Do I need to redraw all the controls like DrawText() ? and then BitBlt()?
The original dialog screen is white.
|
|
|
|
|
whenever i need to draw on a dialog, i put a static 'frame' control in the place where i want to draw. then i get that control's rectangle and limit my drawing to that rect.
CRect outRect;
m_myDrawingRectControl.GetWindowRect(outRect);
ScreenToClient(outRect);
also, you should only do drawing in your CDialog's OnPaint method. if you need to trigger drawing from a timer, just call CDialog::InvalidateRect() with your control's rectangle (as above).
so:
void CDynamicShowTextDlg::OnTimer(UINT nIDEvent)
{
CRect outRect;
m_myDrawingRectControl.GetWindowRect(outRect);
ScreenToClient(outRect);
InvalidateRect(outRect);
}
void CDynamicShowTextDlg::OnPaint()
{
if (IsIconic())
{
...}
else
{
CRect outRect;
m_myDrawingRectControl.GetWindowRect(outRect);
ScreenToClient(outRect);
CPaintDC dc(this);
...
do your drawing here.
use dc as the source for your CreateCompatible* stuff
...
CDialog::OnPaint();
}
|
|
|
|
|
Very very appreciate your help.
|
|
|
|
|
And one more question, even I draw in Timer() function, then WM_PAINT also produced to the system,right?
|
|
|
|
|
|
Hi, I wrote snippet code to test.
first, I put a Static text in the dialog box, from the resource file:
IDD_ECHOBUTTONEVENT_DIALOG DIALOGEX 0, 0, 320, 200
...
BEGIN
...
LTEXT "Static",IDC_STATIC_TXT1,89,59,98,26
...
END
In Ontimer():
CRect outRect;
CStatic* pTxt1Static;
pTxt1Static = (CStatic*)GetDlgItem(IDC_STATIC_TXT1);
pTxt1Static->GetWindowRect(&outRect);
ScreenToClient(&outRect);
InvalidateRect(&outRect);
UpdateData(FALSE);
In OnPaint():
if (IsIconic()) {
...
}
else
{
CRect outRect;
CStatic* pTxt1Static;
pTxt1Static = (CStatic*)GetDlgItem(IDC_STATIC_TXT1);
pTxt1Static->GetWindowRect(&outRect);
ScreenToClient(&outRect);
CPaintDC dc(pTxt1Static);
dc.SetTextColor(RGB(255,0,0));
dc.SetBkMode(TRANSPARENT);
dc.DrawText(_T("My Test"),&outRect,DT_CENTER|DT_VCENTER);
CDialogEx::OnPaint();
}
But, the string "My Test" 's position is not at same position of Static text(IDC_STATIC_TXT1).
offset I guess is about 50 to 100 pixel.
And if I change CPaintDC dc(pTxt1Static) to CPaintDC dc(this), I got nothing, even I stretch the dialog
box to double, triple size.
If I don't use ScreenToClient(&outRect) in OnTimer(), and OnPaint(), I can see "My Test" string, but, need to stretch the dialog;
I set break point, pTxt1Static->GetWindowRect(&outRect); give :
tagRECT = {top=309 bottom=351 left=577 right=724}
run to ScreenToClient(&outRect); give:
tagRECT = {top=96 bottom=138 left=134 right=281}
Could you please help me to see what is the reason?
|
|
|
|
|