|
Nothing in the doc's even hint at this ability, nor would it make sense for it to work based on what the pragma does.
As a workaround you might want to try creating a resource only dll that includes your res, tinker with the build options to build as a static lib, and then use the pragma to link in the static lib.
What are you trying to accomplish ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
I found another way around this. I have existing build .res files and I was wanting an easy way to link to them to pull it into the statically built .exe. I was hoping the pragma comment stuff could pull this off. The reason I thought this might work was because you can feed in various .lib or even .res files into the "Object/Library modules" edit in the Link settings, so I was hoping pragma comment (lib,...) would do the same trick.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Jim Crafton wrote: existing build .res files and I was wanting an easy way to link to them to pull it into the statically built .exe
I had the same problem. I've manually added refences to the source .rc files via the 'Resource Includes' dialog 'Compile-time directives' by adding lines like: '#include "path/res.rc"'.
So between libs i've had to add these statements as needed (i.e. one lib/dll uses resources from another), as well as in any final .exe. It's a pain, but i think the Resource Includes - Compile-time directives is the 'documented' way to do it.
By adding the #include .rc you also make it a dependent, so no risk of the .res being out of date.
How did you end up doing it ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi there,
I am trying to populate a combo box of available com ports.
I call my openSerialport function from my init dialog function but as soon as CreateFile is executed I get an Unhandled Exception error which has the info 0xC0000005 : Access Violation.
Can anyone help???????
Code Below
InitDialog call
BOOL CPTZControlDlg::OnInitDialog()
{
int i, j, hr;
char portStr[7];
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
j=0;
for (i=0 ; i<PORTNUM ; i++)
{
hr = m_serialCtrl->OpenSerialPort(i,0);
if (hr == 0)
{
g_exists[i] = 1;
g_nComPortInd[j] = i;
g_comport[i] = j;
j++;
sprintf(portStr,"COM%d",i+1);
m_comPort.AddString(portStr);
}
else
g_exists[i] = 0;
}
return TRUE;
}
Open Serial port function
int CSerialControl::OpenSerialPort(int pcCommPortInd,int radd)
{
DCB dcb;
BOOL fSuccess;
char pcCommPort[14];
int m_nComPort;
m_nComPort = pcCommPortInd;
sprintf(pcCommPort,"COM1",pcCommPortInd+1);
m_hCom = CreateFile( "COM1",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED,
NULL
);
if (m_hCom == INVALID_HANDLE_VALUE)
{
m_hCom = NULL;
return COMMSERROR;
}
if (radd==0)
{
CloseSerialPort();
return COMMSGOOD;
}
Cheers
Jim
|
|
|
|
|
What happens if you use OPEN_EXISTING instead of CREATE_ALWAYS ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
jimjim733 wrote: sprintf(pcCommPort,"COM1",pcCommPortInd+1);
What is the purpose of the above line?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In addition to the "For communications resources, the dwCreationDisposition
parameter must be OPEN_EXISTING" problem...
jimjim733 wrote: if (m_hCom == INVALID_HANDLE_VALUE)
{
m_hCom = NULL;
return COMMSERROR;
}
NULL is not an invalid handle value. INVALID_HANDLE_VALUE is an invalid
handle value.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
NULL is not INVALID_HANDLE_VALUE , but (I guess) it is still is an invalid handle value.
That's said, I agree with you: he should return INVALID_HANDLE_VALUE.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
|
|
Mark Salsbery wrote: I knew you were going to bring that up!
MS's trap!!!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
If this is possible, I don't think it should be.
To borrow a phrase, "what if you could do this?"
1/ Do you think people who write viruses / trojans / rootkit / bad stuff(tm) would say to themselves "oh, it would be irresponsible of us to use MakeOurAppUnstoppable (), so we'll leave that API only for good people".
2/ You have a bug in your program, and it's in an infinite loop, guzzling memory. How do you close it to put your NewEvenShinierApp.exe?
3/ There is no (3). I'd convinced myself at (1)...
Iain.
|
|
|
|
|
Wonderful.
Good stuff for 'memorable quotes' on my blog.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Why ? Wouldn't this be considered rude ?
|
|
|
|
|
I am not able to think of a legitimate purpose why you want to do this. Why should your process run forever? The user must have the freedom to quit any process that they want to and delete any files that they want to.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: I am not able to think of a legitimate purpose why you want to do this. Why should your process run forever? The user must have the freedom to quit any process that they want to and delete any files that they want to.
How about a software that can keep an eye on all the users logged in to your office network at any given time, and of course the users should not be able to terminate this. Trying to achive something like without using access previlages and no service, it looks he has few windows 9x clients also
|
|
|
|
|
One good use:
Anti-malware, keep the program running as a diagnostic tool.
Ps.
Ring 0, or ring 3 can't think of it.
IF you look at it from a malware writer's perspective, it would usually involve dll injection, dual processes, or creation of a driver.
Whether the code is revealed or not, malware will ALWAYS be written as will diagnostic software.
|
|
|
|
|
But why do you want to do it I want to delete or uninstall your program ?
|
|
|
|
|
|
Anil K P wrote: (users with Admin right and below)
If you can take the Admin out of that list, then this should be possible by carefully assigning the permissions, for the users you may wish to deny.
Anil K P wrote: I can't make this executable a service, but need it as an executable itself.
A service is also an executable. Anyways if you dont like the idea of service, still you can try remote execute your application as an administrator through network.
|
|
|
|
|
I made my dialog box transparent.. so that when i draw something on dialog it looks like i draw on desktop screen. Now when i put another window over the drawn stuff it took previous window background. How do i overcome this.. Below is my code.. Please take a look..
|
|
|
|
|
#include <windows.h>
struct
{
WORD palVersion;
WORD palNumEntries;
PALETTEENTRY palPalEntry[12];
} palPalette =
{
0x300,
12,
{
{0xFF, 0x00, 0x00, PC_RESERVED},
{0xC0, 0x40, 0x00, PC_RESERVED},
{0x80, 0x80, 0x00, PC_RESERVED},
{0x40, 0xC0, 0x00, PC_RESERVED},
{0x00, 0xFF, 0x00, PC_RESERVED},
{0x00, 0xC0, 0x40, PC_RESERVED},
{0x00, 0x80, 0x80, PC_RESERVED},
{0x00, 0x40, 0xC0, PC_RESERVED},
{0x00, 0x00, 0xFF, PC_RESERVED},
{0x40, 0x00, 0xC0, PC_RESERVED},
{0x80, 0x00, 0x80, PC_RESERVED},
{0xC0, 0x00, 0x40, PC_RESERVED}
}
};
POINT pt12[12] =
{
{0, 1000},
{500, 866},
{866, 500},
{1000, 0},
{866, -500},
{500, -866},
{0, -1000},
{-500, -866},
{-866, -500},
{-1000, 0},
{-866, 500},
{-500, 866}
};
void Animate(HWND hwnd, HPALETTE hPalette)
{
HDC hDC;
PALETTEENTRY pe[12];
HPALETTE hOldPal;
static int nIndex;
int i;
for (i = 0; i < 12; i++)
pe[i] = palPalette.palPalEntry[(i + nIndex) % 12];
hDC = GetDC(hwnd);
hOldPal = SelectPalette(hDC, hPalette, FALSE);
RealizePalette(hDC);
AnimatePalette(hPalette, 0, 12, pe);
nIndex = (++nIndex) % 12;
SelectPalette(hDC, hOldPal, FALSE);
ReleaseDC(hwnd, hDC);
}
void DrawCircle(HWND hwnd, HPALETTE hPalette)
{
HDC hDC;
PAINTSTRUCT paintStruct;
RECT rect;
SIZE sizeO;
POINT ptO;
HPALETTE hOldPal;
int i;
hDC = BeginPaint(hwnd, &paintStruct);
if (hDC != NULL)
{
hOldPal = SelectPalette(hDC, hPalette, FALSE);
RealizePalette(hDC);
GetClientRect(hwnd, &rect);
DPtoLP(hDC, (LPPOINT)&rect, 2);
ptO.x = (rect.left + rect.right) / 2;
ptO.y = (rect.top + rect.bottom) / 2;
sizeO.cx = MulDiv((rect.right - rect.left), 2, 3);
sizeO.cy = MulDiv((rect.bottom - rect.top), 2, 3);
for (i = 0; i < 12; i++)
{
HBRUSH hbr;
HBRUSH hbrOld;
hbr = CreateSolidBrush(PALETTEINDEX(i));
hbrOld = (HBRUSH)SelectObject(hDC, hbr);
Ellipse(hDC,
ptO.x + MulDiv(sizeO.cx, pt12[i].x - 259, 2000),
ptO.y + MulDiv(sizeO.cy, pt12[i].y - 259, 2000),
ptO.x + MulDiv(sizeO.cx, pt12[i].x + 259, 2000),
ptO.y + MulDiv(sizeO.cy, pt12[i].y + 259, 2000)
);
SelectObject(hDC, hbrOld);
DeleteObject(hbr);
}
SelectPalette(hDC, hOldPal, FALSE);
EndPaint(hwnd, &paintStruct);
}
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam)
{
static HPALETTE hPalette;
switch(uMsg)
{
case WM_CREATE:
hPalette = CreatePalette((LPLOGPALETTE)&palPalette);
break;
case WM_PAINT:
DrawCircle(hwnd, hPalette);
break;
case WM_TIMER:
Animate(hwnd, hPalette);
break;
case WM_DESTROY:
DeleteObject(hPalette);
hPalette = NULL;
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR d3, int nCmdShow)
{
MSG msg;
HWND hwnd;
WNDCLASS wndClass;
if (hPrevInstance == NULL)
{
memset(&wndClass, 0, sizeof(wndClass));
wndClass.style = CS_HREDRAW | CS_VREDRAW ;
wndClass.lpfnWndProc = WndProc ;
wndClass.cbClsExtra = 0 ;
wndClass.cbWndExtra = 0 ;
wndClass.hInstance = hInstance ;
wndClass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndClass.hbrBackground = (HBRUSH) GetStockObject (HOLLOW_BRUSH ) ;
wndClass.lpszMenuName = NULL ;
wndClass.lpszClassName = "HELLO";
if (!RegisterClass(&wndClass)) return FALSE;
}
hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
"HELLO",
NULL,
WS_POPUP,
10,
10,
200,
200,
NULL,
NULL,
hInstance,
NULL) ;
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
SetTimer(hwnd, 1, 200, NULL);
while (GetMessage(&msg, NULL, 0, 0))
DispatchMessage(&msg);
KillTimer(hwnd, 1);
return msg.wParam;
}
</windows.h>
|
|
|
|
|
Sure, no sweat
First of all, the best approach I can see for this is to use a LayeredWindow approach. This necessitates win2k or higher and just 2 changes to your code.
It also means that 1 of the 2^24 colours available cannot be used, as this is used as the mask colour.
First, goto the line that sets the background for the window class
and change it to (where RGB(255,0,255) represents an arbitrary colour choice)
wndClass.hbrBackground = (HBRUSH) CreateSolidBrush(RGB(255,0,255));
Next, goto the line that updates the window after it's shown
and change it to:
SetLayeredWindowAttributes(hwnd, RGB(255,0,255), 255, LWA_COLORKEY|LWA_ALPHA);
Voila! You should now have a bunch of circles floating on whatever is under them.
Add this code, and you can drag it using the left mouse button.
case WM_LBUTTONDOWN:
SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION,NULL);
break;
In the above code, I have used 255,0,255 as the mask colour.
|
|
|
|
|