|
Victor Nijegorodov wrote: BTW, what do you mean by "... from within a .bat-file."? I want to do it in bat-file language (the language you type in the command prompt C:\Windows\System32\cmd.exe)
|
|
|
|
|
@echo off
set "workdir=C:\MyProject\bin\release"
set "workdir=%workdir:\=\\%"
setlocal enableDelayedExpansion
for /f "usebackq tokens=* delims=" %%a in (`
wmic process where 'CommandLine like "%%!workdir!%%" and not CommandLine like "%%RuntimeBroker%%"' get CommandLine^,ProcessId /format:value
`) do (
for /f "tokens=* delims=" %%G in ("%%a") do (
if "%%G" neq "" (
rem echo %%G
set "%%G"
rem echo !ProcessId!
goto :TheApplicationIsRunning
)
)
)
echo The application is not running
exit /B
:TheApplicationIsRunning
echo The application is running
exit /B
|
|
|
|
|
|
|
Congrats!
|
|
|
|
|
|
That's a lot of magic
If prefer to write my own.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Greetings to everyone. On my Windows 10 PC, I use Avast AV for an extra layer of protection on Windows Defender. But with the installation of Avast AV, the Avast Secure browser was installed. I don't really use it, so if I uninstall Avast Secure Browser, will it cause any problems with Avast AV on my PC? Please, give me some suggestions about this. Any kind of reply would be greatly appreciated.
|
|
|
|
|
In playing around with some basic GDI stuff, I had the need to draw an object in the middle of the main window and then when a button is clicked, draw that object progressively closer to some corner (in my code below, the object moves to the lower right corner, but ultimately I'd like it to move to any corner). So my question is: how to calculate those new X/Y coordinates with each button click?
The initial X/Y coordinates are calculated in response to WM_SIZE like:
case WM_SIZE:
nScreenWidth = LOWORD(lParam);
nScreenHeight = HIWORD(lParam);
nX = (nScreenWidth - nObjectWidth) / 2;
nY = (nScreenHeight - nObjectHeight) / 2;
break; When the button is clicked, new X/Y coordinates are "calculated" like:
case WM_COMMAND:
if (LOWORD(wParam) == ID_BUTTON)
{
nX += 20;
nY += 10;
InvalidateRect(hWnd, NULL, TRUE);
}
break; The object is drawn in response to WM_PAINT like:
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
}
break; You can count on one hand how many GDI projects I've done in the past (and have fingers left over) so I'm walking in somewhat uncharted territory for me. As a visual aide, if you envision a straight line drawn from the middle of the screen to one of its corners, each pixel of that line is on an X/Y coordinate. What would that calculation look like?
Thank you.
DC
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 11-Jan-21 15:00pm.
|
|
|
|
|
David Crow wrote: What would that calculation look like? I don't think it is a straightforward calculation as you would need to move more pixels in the horizontal direction than the vertical (assuming landscape view). If you use GDI+ it is slightly easier as you can use float values for the points and Windows does the smoothing. But I am not 100% clear as to the actual problem. And incidentally, as far as handling messages and repainting, your code all looks correct.
|
|
|
|
|
I started reading about Bresenham's line drawing algorithm last night but haven't had time yet to put anything in place.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Sixty years ago my brain might have been able to handle that. 
|
|
|
|
|
Here is a very simple method of moving the box:
You need to start by calculating the value of the slope ratio between horizontal and vertical size of the Window's client area. You need this as a floating point value as it will be used to calculate positions further on.
Declare a static float value named slopeRatio , and add the following code to either the initialisation (e.g. WM_CREATE), or whenever the Window is resized (WM_SIZE).
RECT rcClient;
GetClientRect(hWnd, &rcClient);
float horiz = (float)rcClient.right; float vert = (float)rcClient.bottom; slopeRatio = horiz / vert;
Then when you need to calculate the new X and Y positions of your drawing (after the button press) do the following:
currentX += 30; tempY = (float)currentX / slopeRatio;
currentY = (int)tempY;
InvalidateRect(hWnd, nullptr, TRUE);
|
|
|
|
|
Does anyone here have to maintain Labview Projects? If so what are thoughts and concerns?
|
|
|
|
|
This[^] looks to be a great place for you to get started.
|
|
|
|
|
so, i was doing some programming with eclipse and stuff. But then i noticed that all of my .JAR files suddenly looked like a pinguin with some painting stuff on his hands. i need help, cause im not sure what is going on!! I use windows.
[SOLVED] I had to right click a JAR file, and "press open in application" then select Java JDK. For some reason i had two of those...
modified 1-Sep-20 4:02am.
|
|
|
|
|
Member 14927382 wrote: (no trashmail please)
and you expect the spammers who have harvested this email to respect that. Remove your email address and rely on CP to notify you when there is a response.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
|
I'm debugging the client's DHСP code on winsock and after receiving DHCPACK I want to check the received IP for a conflict. But I don't know how to. Could someone help with example?
|
|
|
|
|
That would probably depend on what you mean by "conflict"?
|
|
|
|
|
I mean to check retrieved from DHCP server IP address is exist a some device in local network with same IP address or not. If exist I have to send DHCPDECLINE to DHCP server and request another IP address
|
|
|
|
|
What are you writing? This is all handled by the network stack, so a normal application wouldn't even know this was going on.
If the IP is already bound to the adapter, you have no way of knowing that because if you try to ping it using the easy and normal methods, you'll only get a response from your own machine, like "ping localhost".
If you try to do this before the IP is bound to the adapter, you don't have an IP yet, so you can't use the easy and normal methods here either because they rely on the IP already being set. So the only way to do this would be digging deeper into the network stack and crafting your own packets, and that take admin permissions to be able to do that. A normal user wouldn't be able to do that.
In the real world, DHCP servers can be setup to do this themselves, and it's also managed by reserving ranges of IP addresses for static allocation, "ad-hoc allocation", and other ranges for dynamic allocation. Today, you would be hard pressed to get an IP that was in use already from the server.
|
|
|
|
|
|
Well, that changes thing just a bit.
You cannot use a PING to see if something else is using the address. It requires a local IP address to work. After all, where would the target machine send the reply packet to if there's no IP?
I don't know how you're going to reliably do this. An ARP query is about the only way you can determine if an address is in use, but that's not guaranteed.
|
|
|
|
|