|
I want to just write "include "dummycontrol.h"" in cpp file of the other project, and linker will pick it up automatically.
#pragma comment(lib, "yourlib") will do the trick. You'll probably use two #pragmas in #if/#else/#endif, one for debug and one for release. Note that there's no path - you should place the .lib file in one of the dirs listed in Options/Directories/Library files.
I was able to link only when I explicitly put full path to the module
Hmmm... including just the 'yourlib.lib' in the Object/Library modules didn't work?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz, thank you for replay.
Where exacly should I place this #pragma macros (what file)? I'm very new to VC++ - just moved from Delphi, and main headache is all these macros, includes and link options (.
About including just the 'yourlib.lib' in the Object/Library modules - it works.
SY-
Kosta.
|
|
|
|
|
Tomasz, thank you for replay.
Where exacly should I place this #pragma macros (what file)? I'm very new to VC++ - just moved from Delphi, and main headache is all these macros, includes and link options (.
About including just the 'yourlib.lib' in the Object/Library modules - it works.
SY-
Kosta.
|
|
|
|
|
Where exacly should I place this #pragma
In the .h file of your control:
#ifdef _DEBUG
#pragma comment(lib, "yourlibD")
#else
#pragma comment(lib, "yourlib")
#endif
Note that names for debug and release libs should be different. Appending 'D' to the name of library for debug builds is a popular naming convention.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks!!!!
It works now! You are the man!
SY-
Kosta.
|
|
|
|
|
You can put the code that makes up you lib files into a new Win 32 Static or Dll lib project from the new project wizard. Then in the other workspace where you want to use the library, goto the Project menu -> Insert into Project Workspace, and select the .dsp file of the Static lib, remebering to make it a dependency of your new project.
All you have to do then is include the header files for you class\classes that you wish to use.
Hmmm, does this make sense? Hope it helps.
Giles
|
|
|
|
|
In MS Word 97, when I drag any toolbar (such as drawing toolbar) and drop it on the Word window, it becomes a window with small title bar. It makes me surprised that when I click on a button on the toolbar, the cursor on MS Word window still blink and MS Word window is still active. Vice versus, when I type, the toolbar window is still active. I try to create a window like that by the API Fuction CreateWindowEx and set window style as WS_Ex_TOOLWINDOW, and its parent as another window;
However, this window becomes de-active when I click on its parent window. I wish to receive any explaination for this phenomenon. Thank you very much.
|
|
|
|
|
What means "container" on a LAN?
(in the description of "NETRESOURCE" in MSDN)
Is a shared file folder a "container"?
Is a "Work Group" a "container"?
Thanks.
Maer
|
|
|
|
|
A workgroup is surely a RESOURCEUSAGE_CONTAINER, but I think a shared directory or printer is not.
Btw, have a look at this article: http://www.codeproject.com/treectrl/networktreectrl.asp
It may help you to understand how to call WNetOpenEnum.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Thanks again my pal.
I have read your article you introduced to me. It helps a lot.
But I still have a question, that is, are there any other typies of "container" besides "Work Group" on the LAN?
Best regards.
Maer
|
|
|
|
|
Well, I don't know
This is from WinNetWk.h:
#define RESOURCEDISPLAYTYPE_GENERIC 0x00000000
#define RESOURCEDISPLAYTYPE_DOMAIN 0x00000001
#define RESOURCEDISPLAYTYPE_SERVER 0x00000002
#define RESOURCEDISPLAYTYPE_SHARE 0x00000003
#define RESOURCEDISPLAYTYPE_FILE 0x00000004
#define RESOURCEDISPLAYTYPE_GROUP 0x00000005
#if(WINVER >= 0x0400)
#define RESOURCEDISPLAYTYPE_NETWORK 0x00000006
#define RESOURCEDISPLAYTYPE_ROOT 0x00000007
#define RESOURCEDISPLAYTYPE_SHAREADMIN 0x00000008
#define RESOURCEDISPLAYTYPE_DIRECTORY 0x00000009
#endif /* WINVER >= 0x0400 */
#define RESOURCEDISPLAYTYPE_TREE 0x0000000A
#if(WINVER >= 0x0400)
#define RESOURCEDISPLAYTYPE_NDSCONTAINER 0x0000000B
#endif /* WINVER >= 0x0400 */
My guess is that a container is: ROOT, NETWORK, SHAREADMIN, NDSCONTAINER, GROUP, DOMAIN, SERVER, maybe TREE
But absolutely not sure!
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Thanks again.
But if I do not know the typies of "container", how can I know whether a "NETRESOURCE" is a container that contain sub-"NETRESOURCE"?
From which flag can I know?
Best regards.
Maer
|
|
|
|
|
The RESOURCEUSAGE_CONTAINER does this, but to know if it actually contains something you have to call WNetOpenEnum().
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi,Paolo.
Thanks again.
In your reply, you said "The RESOURCEUSAGE_CONTAINER does this", but how about the value of "dwScope" at the same time?
(I mean should I test the whether the value is "RESOURCE_GLOBALNET & RESOURCEUSAGE_CONTAINER" or "RESOURCEUSAGE_CONTAINER"?)
Should the value of "dwScope" be "RESOURCE_GLOBALNET"?
Hope you can help.
Best regards.
Maer
|
|
|
|
|
You may safely ignore the dwScope flags.
Only check if (dwUsage & RESOURCEUSAGE_CONTAINER) is non-zero.
This is what I did in the article's demo prject, and it works
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi, Paolo.
You method works perfectly. But it can not emun the shared folders and shared files?
How to resolve the problem?
Maer
|
|
|
|
|
Yes, I know that. You can see also in my demo project that the last item in the tree structure is a shared folder.
You have to take the path of the shared folder and continue enumeration using FindFirstFile/FindNextFile (appending a "\*.*" or whatever mask you want to the path).
Enumeration of local files/folders (even if shared) is not responsibility of the WNet APIs, but you have another way.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
I have an ini file that I use to hold system settings.
I do not want the user to be able to open it and change values.
Can an ini file be encripted and still read and written using
GetPrivateProfileString and
WritePrivateProfileString
thank you.
|
|
|
|
|
You can't encrypt the entire file and still have it work with Get/WritePrivateProfileString, but you *can* encrypt the data before saving it to the INI file, and decrypt it after reading. However, if one of the encrypted strings contains a semi-colon, you may not get all your data back because that character represents the start of a comment in the file.
I would use a binary data file and encrypt/decrypt the data into/from there, or use the registry.
|
|
|
|
|
Have you ever heard about Multiple File Streams feature supported by NTFS file system?
If not, I recommended you to read technical article from on MSDN from Dino Esposito:
"A Programmer's Perspective on NTFS 2000 Part 1: Stream and Hard Link"
It can give you one idea how to easilly do it without file encryption
Martin
--->
|
|
|
|
|
How to initialize the follow parameter in "NETRESOURCE"?
( I ues the structure for the next call to "WNetOpenEnum")
LPTSTR lpLocalName
LPTSTR lpRemoteName
LPTSTR lpComment
LPTSTR lpProvider
Can you show me an example in practice?
Thanks.
Maer
|
|
|
|
|
I think you only need lpRemoteName and some flags.
You may also consider to use the shell and SHGetDataFromIDList if you have a PIDL of the net resource. You may obtain that by parsing a network path with SHGetDesktopFolder and IShellFolder::ParseDisplayName.
But it's surely easier to try with the first method
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi, my pal.
Thanks for your reply.
I have read the information about SHGetDesktopFolder, IShellFolder::ParseDisplayName, SHGetDataFromIDList in MSDN.
Can you show me a sample code using the functions you mentioned before to get the first level of "NETRESOURCE" of the "Network Neighborhood"?
Thanks again.
Best regards.
Maer
|
|
|
|
|
(the follow is from MSDN)
BOOL WINAPI EnumerateFunc(HWND hwnd,
HDC hdc,
LPNETRESOURCE lpnr);
What is the function "WINAPI" here?
Thanks.
Maer
|
|
|
|
|
WINAPI specifies the calling convention of the function. The calling convention is the set of rules followed to pass arguments to and invoke a function. Some aspects a calling convention must define are- Whether parameters are stored in registers or in the stack,
- the order in which parameters are stored in the stack (first parameter the first to be pushed or the other way round),
- whose responsibility it is to clean the stack after return,
- how the return parameter is passed from the function to the invoker.
So, different languages typically specify different calling conventions (notably, the Pascal calling convention is that the callee clean the stack before returning, whereas in C it is the caller that does the job). If a function is invoked with a different calling convention than expected, crash is almost sure to happen.
The language C (as implemented by Microsoft) allows the specification of the calling convention of a function so that you can invoke it even if it does not follow the C calling convention. Some calling conventions are:__cdecl , the C default calling convention,
__stdcall , aka PASCAL ,
__fastcall , __thiscall , etc.
WINAPI is simply a macro for __stdcall , and ensures that your program calls Windows APIs the Pascal way.
Why do Win32 APIs use the Pascal calling convention instead of __cdecl ? Remember that these functions inhabit global DLLs of the system and are invoked by different programs written in different languages, so they just had to stick to some particular convention.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|