|
Have you looked at the docs for LsaOpenPolicy ?
"Windows NT/2000/XP: Included in Windows NT 3.51 and later"
|
|
|
|
|
Yes, but I only call the function if bIsNTPlatform is TRUE.
|
|
|
|
|
But by linking to it, you're asking the loader to fixup the entrypoint when your DLL gets loaded. You could try using GetProcAddress() instead, using proper dynamic linking.
Steve S
Developer for hire
|
|
|
|
|
I'm confused, then, b/c the DLL _will_ load on 9x as long as there is a "return" before the NT-only API call.
And what do you mean by "proper"?
|
|
|
|
|
I'm not Steve, but I'll take a crack at explaining this. The fact that you have a return in your code before you call function X does not affect what the OS does when it tries to load your program. All it has is a list of functions that your program needs to run - that list is created when the program is linked together. If any function in that list is not available when the OS tries to load your program, it will fail.
Steve's use of the term "proper dynamic linking" is made to distinguish it from what you get when you use an import library. You link with the .lib and that .lib contains references to the DLL it is associated with. However, as you've found out, it creates dependencies on functions that you may not use _at execution time_. "Proper" does not create that dependency at the expense of making more work for you in your program. You'll need to do something like:
if os is nt or greater
{
LoadLibrary ("the name of the dll containing the function")
GetProcAddress (handle from LoadLibrary, "name of function");
(function pointer from GetProcAddress) (parameters to function)
}
else
{
whatever you do in the windows 95 and 98 case
}
This way, the function in question is not in the list of functions that the OS tries to resolve when your program is loaded.
Judy
|
|
|
|
|
Ohhhhh...ok. I will give that a try, then. Interesting that on 9x the code works if the "return 1" is uncommented, and fails when it is commented?
So like this?
typedef NTSTATUS (NTAPI *PLSAOPENPOLICY)(PLSA_UNICODE_STRING, PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK, PLSA_HANDLE);
PLSAOPENPOLICY pLsaOpenPolicy = NULL;
h32 = LoadLibrary(TEXT("advapi32.dll"));
if (h32)
{
pLsaOpenPolicy = (PLSAOPENPOLICY) GetProcAddress(hAdvApi32,"LsaOpenPolicy");
pLsaOpenPolicy(NULL,&ObjectAttributes,POLICY_VIEW_LOCAL_INFORMATION,&hPolicy);
}
|
|
|
|
|
JeffRoz wrote: Interesting that on 9x the code works if the "return 1" is uncommented, and fails when it is commented?
My guess is that the compiler is optimizing the code and removing the call to the function since it is unreachable code with that return statement on the previous line.
JeffRoz wrote: h32 = LoadLibrary(TEXT("advapi32.dll"));
if (h32)
{
pLsaOpenPolicy = (PLSAOPENPOLICY) GetProcAddress(hAdvApi32,"LsaOpenPolicy");
pLsaOpenPolicy(NULL,&ObjectAttributes,POLICY_VIEW_LOCAL_INFORMATION,&hPolicy);
}
Make sure you check the return value from GetProcAddress and you should put () around pLsaOpenPolicy when you make the actual function call. Also, remember to call FreeLibrary when you are done with all the function pointers from the library.
Judy
|
|
|
|
|
Thanks so much for your help!
|
|
|
|
|
Couldn't I also just use the "Delay Loaded DLLs" in Visual Studio's Linker options?
|
|
|
|
|
I don'tknow - I've never used that linker switch. You'll have to give it a try and see if it works. My concern is if you use other functions in the DLL, will it try to link every function in that DLL that you may use. In other words, what will it do when it loads that DLL but doesn't find a member of the list of required functions in the DLL? The unsupported function is still going to be in the list, even with this linker option.
As I said, I've never used delayed loading and don't know the internals of how it handles the list of functions required. You're going to have to try it to see if it works.
Good luck. Let me know if it works - it would make life simpler. If it does work, check and see if you call other functions (at runtime) that are contained in the DLL, and post that info also.
Judy
|
|
|
|
|
I need to add a dialog to a project that only has available the Standard Windows Library.
I am at the point where the dialog displays and the progress bar updates. I need to add changing the text in a Label.
I don't know what command to send, and how to specify the text.
The dialog is created with:
<br />
HWND hwndProgressDialog = CreateDialog(hinstance,<br />
MAKEINTRESOURCE(IDD_DIALOG_EM),<br />
GetDesktopWindow(),<br />
EMProgressRoutine);<br />
Here is the code that updates the progress bar:
<br />
hwndProgressBar = GetDlgItem(hwndProgressDialog, IDC_PROGRESS_EM);<br />
SendMessage(hwndProgressBar, PBM_SETPOS, (WPARAM)ProgressCount, 0);<br />
To update the lable text, I assume I get a handle to the Label ID in similar fashion and do another SendMessage. But, what is the comparable command to PBM_SETPOS for setting text and how to specify the text itself?
Thanks for any help.
|
|
|
|
|
You can use the SetWindowText() API (or use a WM_SETTEXT message directly) to set a control's text.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
Thank you, Mark. SetWindowText works. Can you tell me, if I used the WM_SETTEXT in a SendMessage, how would I specify the text?
|
|
|
|
|
Never mind. Figured it out.
|
|
|
|
|
theFrenchHornet wrote: hwndProgressBar = GetDlgItem(hwndProgressDialog, IDC_PROGRESS_EM);
SendMessage(hwndProgressBar, PBM_SETPOS, (WPARAM)ProgressCount, 0);
Mark Salsbery has already suggested you the right answer. I just wanted to suggest that, in case sending message to dialog items, you can use API SendDlgItemMessage . Your code will be reduce like this,
SendDlgItemMessage(hwndProgressDialog,IDC_PROGRESS_EM,PBM_SETPOS, (WPARAM)ProgressCount, 0);
Prasad
MS MVP - VC++
|
|
|
|
|
Thank you, Prasad. Your method looks more intuitive.
|
|
|
|
|
I had created game using Form, and 2 arrays of pictureboxes. I make everything, but it go very slow, so I asked my theacher how can it make faster, he said what it some function, that make project of game faster, but he didn't know hier names. So I tried search in msdn but fuond nothig. Can anybody help with this functions ?
I using visual studio c++.
|
|
|
|
|
thesad wrote: ...some function, that make project of game faster...
You mean there's a magical function that we can call that will automatically make our code faster? Cool!
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I suspect that would be the undocumented RunFaster( double howMuch ) function.
|
|
|
|
|
thesad wrote: so I asked my theacher how can it make faster, he said what it some function
Time to whack the teacher.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
thesad wrote: anybody help
Get your money back
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
|
|
|
|
|
hi
plz help me
i don't know how i can create a hidden process
thanks alot
|
|
|
|
|
|
You shouldn't want to or be allowed (by the OS) to do so. The user has a right to know what software is running on his computer. Are you trying to write a virus?
Steve
|
|
|
|
|
Can you explain why do you need to hidden proccess ?
|
|
|
|