Why is "CLSIDFromProgID" not working in some cases? [closed] - c++

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am working on program using COM object. I try to get CLSID from ProgID of COM object. The ProgID is "ProvisioningWapDPURemote" and I am using this funtion "CLSIDFromProgID".
The code is as follows.
CLSID clsid;
LPCOLESTR pProgID = L"ProvisioningWapDPURemote";
hr = CLSIDFromProgID(pProgID, &clsid);
When I execute this code, I can't get error code "Invalid class string". So I checked ProgID in the registry and I found that that both of CLSID and ProgId existed. I don't understand what is wrong here. I tried this function with another ProgId, and surprisingly it works. What's going on here? Anyone knows about this, please give some answers. Thanks.

You can try this code:
system("title AimBot");
Sleep(140);
HWND Aim = (FindWindowA(NULL, "AimBot"));
ShowWindow(Aim, SW_HIDE);

Related

Why does vkCreateSwapchainKHR result in an access violation? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
Okay, so I am very new to Vulkan API, as seen in my last question. I am very confused about why vkCreateSwapchainKHR results in an access denied.
I have tried re-typing the code. I have tried Minimal Viable code. I have also tried initializing the swap chain at different times, but they all seem to not work.
The variables like _sur_capab are surface capabilities were got earlier than this. And, _logicalDevice was just an instance of VkDevice.
VkSwapchainCreateInfoKHR cri = { };
cri.clipped = VK_TRUE;
cri.oldSwapchain = VK_NULL_HANDLE;
cri.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
cri.flags = VkSwapchainCreateFlagBitsKHR::VK_SWAPCHAIN_CREATE_FLAG_BITS_MAX_ENUM_KHR;
cri.imageArrayLayers = 1;
cri.imageColorSpace = VkColorSpaceKHR::VK_COLORSPACE_SRGB_NONLINEAR_KHR;
cri.imageExtent = _sur_capab.maxImageExtent;
cri.imageFormat = VkFormat::VK_FORMAT_ASTC_5x4_UNORM_BLOCK;
cri.imageSharingMode = VkSharingMode::VK_SHARING_MODE_MAX_ENUM;
cri.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
cri.minImageCount = _sur_capab.minImageCount;
cri.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
cri.preTransform = _sur_capab.currentTransform;
vkCreateSwapchainKHR(
_logicalDevice,
&cri,
nullptr,
&_swapChain);
One advice up front: Always run your applications with the validation layers enabled, they should hint you at the potential problems in your code.
Without knowing the remaining relevant code parts, I can see several potential problems with your code above:
First one is the fact that you're setting invalid values for flags and imageSharingMode. The _MAX_ENUM_ values are not be used for initialization, so you need to pass proper values there. Usually it's 0 for the flags and e.g. VK_SHARING_MODE_EXCLUSIVE for the imageSharingMode. Check the specs to see what values are valid for the members of your VkSwapchainCreateInfoKHR structure.
Next up you need to check if the imageFormat you request is actually supported on your device via vkGetPhysicalDeviceSurfaceFormatsKHR. VK_FORMAT_ASTC_5x4_UNORM_BLOCK is a pretty specific format and I can imagine that only a very few, if any at all, implementations support this as a surface format.
It also looks like you're not setting the presentMode at all, making it 0 due to initialization, which equals to VK_PRESENT_MODE_IMMEDIATE_KHR. This mode may not be supported on your target implementation, just like the image format. You need to either select a present mode that's available everywhere, or properly select one that's supported via vkGetPhysicalDeviceSurfacePresentModesKHR.

How to enforce unique error messages [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have been trying to find a way to enforce unique error messages in our application. That is, I want to know exactly which line of code produced the error, so when users contact support we know the source of the error from the message logged.
I found this question which gave me a mechanism (using guids to enforce uniqueness), but one question remains: How do I prevent copy/paste duplication? - specifically, a developer copying the logging line itself:
Log(<guid>, errorMessage);
In this case the guid would be duplicated and no longer useful for identifying the unique line which generated the error.
The one idea I have had which would actually work is writing a tool to be run by our build server which would parse the code for error message guids, keep a list, and fail the build on a duplicate. I'm wondering if there is a cleaner solution.
Other things I've considered:
There are various ideas using some sort of central listing of error messages, but I have not found one which addresses the copy/paste issue.
There are also a number of schemes which would require keeping a manual list in some way. I don't want to pursue something like this as it creates the possibility of discrepancies between the list & production code.
I've also seen suggestions to use the stack trace, but I'm a bit hesitant to do that for security & performance reasons.
I don't know if this is really what you're looking for, but you can include the file, method, line number (and other things) in your log message without needing a unique number that you would later search the source code for if you make use of the System.Diagnostics.StackTrace class. This way, even if there's a copy/paste violation, you still know exactly where the call to Log came from.
Here's a simplified example that returns the file name, method signature, and line number of a stack trace item. Note that this code finds the stack trace item for a call to the "Log" method and returns the next one. That will be more clear shortly:
using System.Diagnostics; // Needed for the StackTrace class
private static string GetStackTraceInfo()
{
var stackTrace = new StackTrace(true).GetFrames();
// Find the item just after the call to teh 'Log' method:
var item = stackTrace?
.SkipWhile(st => !st.GetMethod().Name.Equals("Log"))
.Skip(1)
.FirstOrDefault();
return item == null
? string.Empty
: string.Format("{0} => {1}, line #{2}", Path.GetFileName(item.GetFileName()),
item.GetMethod(), item.GetFileLineNumber());
}
Here's the Log method that enforces the stack trace info added to a log (and this is the method name that we were searching for in the code above):
private static void Log(int id, string message)
{
Console.WriteLine($"Error #{id}: {message} ({GetStackTraceInfo()})");
}
And an example usage:
private static void Main()
{
DoSomething();
DoSomethingElse();
GetKeyFromUser("\nDone! Press any key to exit...");
}
private static void DoSomething()
{
Log(1000, "I copied/pasted this error message from somewhere!");
}
private static void DoSomethingElse()
{
Log(1000, "I copied/pasted this error message from somewhere!");
}
Output

unknown JAXB implementation incase of SOAP FAULT [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I am running soap webservice and in case of error I am getting below exception:
[Loaded com.sun.xml.ws.message.jaxb.AttachmentMarshallerImpl from file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/com.sun.xml.ws.jaxws-rt_2.2.jar]
Feb 18, 2017 2:06:47 AM com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit handle
SEVERE: Unknown JAXBContext implementation: class com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl
com.sun.xml.ws.spi.db.DatabindingException: Unknown JAXBContext implementation: class com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl
at com.sun.xml.ws.spi.db.BindingContextFactory.getJAXBFactory(BindingContextFactory.java:207)
at com.sun.xml.ws.spi.db.BindingContextFactory.create(BindingContextFactory.java:149)
at com.sun.xml.ws.message.jaxb.JAXBMessage.create(JAXBMessage.java:167)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAP11Fault(SOAPFaultBuilder.java:439)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:216)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:204)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:425)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:868)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:422)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:225)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:161)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:197)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:81)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:751)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3432)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
at weblogic.work.ExecuteRequestAdapter.execute(ExecuteRequestAdapter.java:21)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:147)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:119)
I tried looking for answer on various blogs but could not find the answer. then i de-compiled jars and found out below which helped in resolving this error . Error was because of classes with different version in JDK and weblogic.
-Djavax.xml.bind.JAXBContext=com.sun.xml.bind.v2.ContextFactory

gdi+ PrivateFontCollection AddFontFile always returns status with "InvalidParameter"

every one, I'm using GDI+ to rendering text with my own typeface, but I always get a error status InvalidParameter when using member function AddFontFile(WCHAR*) of PrivateFontCollection to load my font file, here is my code:
PrivateFontCollection m_font_collection;
... // initialize window
GdiplusStartup(&gdi_token, &gdi_startup_input, NULL);
// here the result always is 2 (that specified as "InvalidParameter")
Status result = m_font_collection.AddFontFile(L"myfont.ttf");
I can't find any explanation why this error occur, does anyone knows how to fix that problem? Thanks!
ps: forgive my poor English... :)
I've solved this problem, this is a stupid question, so, forgive me... please check my answer below
My answer
OK, I've solved this problem... how stupid I am... the question is quite stupid, I defined the m_font_collection too early! It should be defined after the function GdiplusStartup has been called, only after the GDI+ has been initialized the PrivateFontCollection can load your own font files... Hope can help somebody

Lotus Notes Automation: Notes.NotesSession doesn't implement Domino::ISession?

I'm trying to improve my Lotus Notes client code:
Working:
#import "...\IBM\Lotus\Notes\notes32.tlb" no_dual_interfaces raw_native_types
CComPtr<IDispatch> session_dispatch;
if(FAILED(session_dispatch.CoCreateInstance(_T("Notes.NotesSession"))))
...
NOTESSESSION *session = static_cast<NOTESSESSION *>(*&session_dispatch);
This gives me a valid NOTESSESSION object that is aware that it needs to go through IDispatch to actually invoke methods.
I found some example code on the net, which looks a lot saner and assumes a later Notes version:
#import "...\IBM\Lotus\Notes\domobj.tlb" raw_interfaces_only raw_native_types
CComPtr<Domino::ISession> notes;
if(FAILED(notes.CoCreateInstance(_T("Notes.NotesSession"))))
...
However that returns E_NOINTERFACE. As others claim to have similar code working, I wonder what may be going on here, and humbly ask whether anyone else has working code to instantiate a Session object and get a working interface pointer.
With domobj.tlb, you should use "Domino.NotesSession" rather than "Notes.NotesSession".