|
Sorry, I misread something somewhere.
|
|
|
|
|
Just use the full path for the lpApplicationName parameter.
Avoid using partial names. When using them you have to ensure that the current working directory is set to the parent of the partial name resulting in a path containg that file.
The only exception is when you know that the application is stored in one of the directories specified in the PATH environment variable. Then you can use the plain file name.
|
|
|
|
|
The problem with using the full path name if my .exe is stored in c:\dira\dirb GetCurrentDirectory only returns c:\dira my module is stored in the current directory
Thanks
modified 24-Jul-18 5:43am.
|
|
|
|
|
You have to know (and usually will know) where the file is stored. Where is the problem using the full path?
GetCurrentDirectory() returns the actual working directory of the session. It is not related in any way to the application calling that function (besides the application has set the working directory explicitly).
Again: Use full pathes. If necessary create them dynamically during runtime. But never expect the current working directory to be a specific one if you have not set it. But when setting it, you can also create full pathes instead.
If you need to know where the application actually executed is stored, access the first command line parameter argv[0] in your main() function. That contains the full path of the executable. Or use the GetModuleFileName function (Windows)[^] with the first parameter set to NULL . With both methods you can extract the path which can be for example used to access other files known to exist in the same directory or a sub directory.
|
|
|
|
|
This helps I’ll look into this thanks
|
|
|
|
|
I have a technical interview with Amazon next month. Would like to know your tips/advice on best practices/ways to crack the Amazon interview.
I've started practicing amazon coding interview questions from here and geeksforgeeks.
Can you tell me on which things I should focus more? Data structure/algos/dp? or something else?
Thanks.
|
|
|
|
|
There is no shortcut to 'cracking' an interview, since no one knows what questions will be asked. Just make sure you know everything about the technology that you are being asked to work on.
|
|
|
|
|
You may find a lot of useful info on the web. Google is you friend. There are even books on this very argument. Good luck!
|
|
|
|
|
We need to reduce touchpad cursor speed in certain state in our application. So, i was planning that when the application enter a specific state, we will change touchpad cursor speed at run time by using some Windows API. And when coming out of the specific state, revert the touchpad cursor speed to original value.
However, i did not find any Windows API to change touchpad 'Cursor speed' dynamically without restarting. I found API to change mouse speed (SystemParametersInfo). But this API only changes the mouse cursor speed. It does not change touchpad cursor speed.
I tried changing the below registry. But the problem with changing registry is that touchpad cursor speed gets updated only after system restart. I need an API to change touchpad cursor speed without restarting system (similar to how we can change mouse speed using SystemParametersInfo)
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\CursorSpeed
Any suggestions in this regard will be really very helpful.
|
|
|
|
|
If you change the touchpad cursor speed at the control panel, the change occurs immediately. So there must be some method of notifying Windows that the change has been made. This may be through WMI: take a look at the WMI documentation. Or PowerShell.
|
|
|
|
|
Member 9453331 wrote: I tried changing the below registry. But the problem with changing registry is that touchpad cursor speed gets updated only after system restart. I need an API to change touchpad cursor speed without restarting system (similar to how we can change mouse speed using SystemParametersInfo)
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\CursorSpeed
Any suggestions in this regard will be really very helpful.
If you need to restart the touchpad driver then you could probably use the Setupapi. I believe that you will need to first call SetupDiSetClassInstallParams with the SP_CLASSINSTALL_HEADER.InstallFunction set to DIF_PROPERTYCHANGE followed by a call to the SetupDiCallClassInstaller function with the DI_FUNCTION also set to DIF_PROPERTYCHANGE.
Be aware that many touchpad drivers are written by third-party vendor (i.e. not Microsoft). I don't think all touchpad drivers support being restarted from the Setup API. It really depends on how the third-party vendor has implemented their driver co-installer.
The Windows operating system is 'aware' of the co-installer capabilities from when the co-installer was registered. If you want to check if your touchpad supports enable/disable then go into the device manager and right click... if you see 'Disable Device' then that means that the co-installer supports device restart.
Believe it or not the touchpad device driver itself probably supports start/stop so there is nothing preventing you from developing a co-installer and registering it as the handler for the third-party touchpad driver as long as the co-installer DLL is not part of a digitally-signed catalog.
Best Wishes,
-David Delaune
|
|
|
|
|
The C++ API doesn't seem to provide a similar registration interface for device as is provided by the Java. Before I forge ahead and write on myself I want to verify I am not overlooking anything.
The Java API that (I believe) accomplishes registration of a device is:
public static void createDeviceWithEs256(String deviceId, String publicKeyFilePath,
String projectId, String cloudRegion, String registryName)
throws GeneralSecurityException, IOException {
GoogleCredential credential =
GoogleCredential.getApplicationDefault().createScoped(CloudIotScopes.all());
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
HttpRequestInitializer init = new RetryHttpInitializerWrapper(credential);
final CloudIot service = new CloudIot.Builder(
GoogleNetHttpTransport.newTrustedTransport(),jsonFactory, init)
.setApplicationName(APP_NAME).build();
final String registryPath = String.format("projects/%s/locations/%s/registries/%s",
projectId, cloudRegion, registryName);
PublicKeyCredential publicKeyCredential = new PublicKeyCredential();
final String key = Files.toString(new File(publicKeyFilePath), Charsets.UTF_8);
publicKeyCredential.setKey(key);
publicKeyCredential.setFormat("ES256_PEM");
DeviceCredential devCredential = new DeviceCredential();
devCredential.setPublicKey(publicKeyCredential);
System.out.println("Creating device with id: " + deviceId);
Device device = new Device();
device.setId(deviceId);
device.setCredentials(Arrays.asList(devCredential));
Device createdDevice =
service
.projects()
.locations()
.registries()
.devices()
.create(registryPath, device)
.execute();
System.out.println("Created device: " + createdDevice.toPrettyString());
}
[^]
Any comments much appreciated.
Tom
|
|
|
|
|
That looks more like a set of Google API calls, than native Java.
|
|
|
|
|
I have a MDI app, with view based on CHtmlView. Is there any way to launch every CChildFrame in separate thread ? If yes, how can I do that ? I search on internet for this, but I have found nothing ...
|
|
|
|
|
The frames belong to the GUI and should be therefore executed in the GUI (main) thread. I even don't think that it is possible to run the child frames in another thread due to the relationship to the main frame, and the views. Even if it is possible, it would be a nightmare to make it all thread safe.
But you can execute specific operations within the child frames or the views in separate threads. A common method is to use worker threads for longer running jobs. Because such threads can not directly access (MFC) UI elements, they have to post (user defined) messages to update UI elements.
|
|
|
|
|
My task is to run some specific html pages, but sending some forms inside these page is taking a little more time, and there is 8-10 html pages ... I was thinking that running every child frame in separate thread would be a good solution ... but I guess is not ... hmm ... I don't know how to shrink the time when these html pages work their tasks ...
|
|
|
|
|
You can still use threads to do the work and provide some kind of wait indication (cursor, status line, or self closing notification / progress window).
The advantage of using threads is that the GUI is not blocked and the user can do other operations meanwhile.
But using threads is not making something that requires an amount of time running faster (besides splitting the work and letting multiple threads perform the work in parallel). It just allows doing something else meanwhile.
|
|
|
|
|
You are perfectly right. Here is the scenario: I should start 8 CHtmlViews, every one of them with a specific web address, and do a login form. Now, every login task, take 3-4 seconds. If a do this for every 8 pages, the time until all 8 pages complete the login is ~30, 35 seconds, but, most important, the main thread, the GUI thread is blocked.
That is why I am trying to run every CHtmlView on separate thread, not because the login task is taken less time, but because is not block the main GUI thread ...
|
|
|
|
|
Put the communication tasks into there own threads and display a place holder in the view meanwhile. Once the communictaion is done, update the view with the data received in the background.
|
|
|
|
|
Unfortunately, the communication with the server is done by html page ...
|
|
|
|
|
If have not used CHtmlView so far but I'm quite sure that the networking is done in a separate thread and there are notification messages informing you when a page has been loaded. Anything else would make no sense because a large download would block your GUI.
If your GUI is blocked, you are probably waiting somewhere inside a loop instead of handling notifications.
|
|
|
|
|
This is a good news. So, I will launch view after view to do a login to see how is moving my GUI ... if I think well, there is some methods on this CHtmlView which reveal that all tasks inside html gui is made somewhere in backside (I guess):
CHtmlView::OnBeforeNavigate2
CHtmlView::OnDocumentComplete
CHtmlView::OnDownloadBegin
CHtmlView::OnDownloadComplete
CHtmlView::OnNavigateComplete2
CHtmlView::OnNavigateError
CHtmlView::OnUpdateUI
modified 17-Jul-18 1:57am.
|
|
|
|
|
I have few methods, in a CDocument class, which read from IHTMLElement get_tagName.
BSTR bstrTagName;
CString sTempTagName;
if (! FAILED(pElem->get_tagName(&bstrTagName)))
{
sTempTagName = bstrTagName;
sTempTagName.MakeLower();
AfxMessageBox(sTempTagName);
SysFreeString(bstrTagName);
}
which show in MessageBox html tags: input, div, span, and so on ...
if I try
BSTR bstrTagName;
CString sTempTagName;
if (! FAILED(pElem->get_tagName(&bstrTagName)))
{
sTempTagName = bstrTagName;
sTempTagName.MakeLower();
TRACE("%s\n", sTempTagName);
SysFreeString(bstrTagName);
}
I have in my debug window the first letter of every read tag:
i
d
s
and no entire html tag ... why in MessageBox I see whole word, but in TRACE macro I don't ?
|
|
|
|
|
The debugger does not always recognise that a character array may be Unicode, so you need to add the type to the variable name or address in the watch window.
|
|
|
|
|
You may need to add ,s or ,u to the variable being watched in the Watch window.
"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
|
|
|
|