我该如何书写和调用这种类型

How do i write and call this type

本文关键字:调用 种类 类型 书写 何书写      更新时间:2023-10-16

我这里有个问题,问题是hService0

我有或创建Windows窗体应用程序,我已经放:

HSERVICE hService=0;
BOOL fSuccess=EXIT_SUCCESS;
if(Wfs_Startup())
{
     // This returns a successful startup even if I write something here 
     // to be displayed by a textbox it does. That means the Startup is ok.
     if(Wfs_Open(&hService))
     {
         // What ever I put here doesn't show on a textbox and the application jumps to
         // the exception of this block which means there's a problem here, at first I 
         // thought it was because of no corresponding logical name on a registry but what 
         // I found out was that if I check below the Startup block and check the hService 
         // it's 0 so it doesn't receive the correct data from the startup.
    }
}

所以我从"我会说"这个函数中得到了这个:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdDLine, 
                                                                            int nShowCmd)
{
    //THE CODE BLOCK IS THE SAME AS THE ABOVE THAT GOES HERE.
}

所以我把内部代码块带到了FormLoad,但这给了我上面提到的问题,我可以同时拥有FormLoadWinMain吗?因为我试着用WinMain,但出现了一个错误,我想它说不可能有两个Main或类似的东西。此外,我如何在FormLoad中调用WinMain,因为当我尝试时,它需要包含参数,而主要问题是我无法在FormLoad中添加参数。

关于我该如何解决这个问题,有什么建议吗?

抱歉,但不知道简单的解释方法。但是请记住hService返回0的问题。

好的,只是为了简化这个问题:

如何调用这种开头以HRESULT开头的函数,请查看上面的内容。我想要的是激发那个函数,我认为这会简化它,尽管在FormLoad上调用它还有另一个问题,但首先我想知道如何调用/激发那种函数?

问题是IDE说我不能在Windows窗体上使用int WinMain,因为它已经有了类似的东西,但当我使用命令时,它就可以工作了。我可以有WinMain和Main,但不能让WinMain和FormLoad不在项目或页面内。为了理解,请创建一个Windows窗体应用程序,并尝试键入int WinMain代码,你会在这里看到我的问题所在。

我找到了一个很棒的教程,它为我遇到这个问题提供了一个很好的理由:

https://msdn.microsoft.com/en-us/library/bb384843.aspx