|
of course should be SHGetSpecialFolderPath and not SHGetSpecialFolderLocation
-----------
Mila
|
|
|
|
|
char szPath[255];
if(SUCCEEDED(SHGetSpecialFolderPath(NULL,szPath,CSIDL_FAVORITES, 0)))
{
MessageBox(szPath);
}
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hi Everybody,
I'd like to know how to get the windows installed drive?
If I installed Windows in C: drive, the result should be "C:".
Is there any API available to get this?
Thanks in advance,
Sarvan AL
*** Live Lift To Its Fullest ***
|
|
|
|
|
Use
GetWindowsDirectory()<br />
<pre> char cBuf[255];
GetWindowsDirectory(cBuf,255);
MessageBox(cBuf); </pre> <br />
This will give you the path to windows directory however. <br />
<br />
<div class="ForumSig"><font face="Verdana" color="Crimson" size="1.4">Nobody can give you wiser advice than yourself. - Cicero</font></div>
|
|
|
|
|
|
How to get the System Name & IP Address in Linux using C.
I m using gcc compiler.
I tried it using code for getting System Name & IP in Window , but output I am getting is "localhost.localdomain" & "127.0.0.1" (but system has IP).
Also how to get/check the System Name in Linux Environment?
Plz. help me.
Sorry I didn't found the exact Community for my que.
|
|
|
|
|
Hi,
You have to include following headers: <netdb.h> <arpa/inet.h>
By using gethostbyname(name) you will get hostent structure filled with available information about host under the name specified as parameter.
By using gethostbyaddr(addr, len, type) you will get hostent structure filled with available information about host under specified IP address.
In order to get system name, you can use h_name member of hostent structure.
To get IP address/es, you can use h_addr_list member of hostent structure to list all associated addresses or use h_addr pointer to first available address.
Example:
struct hostent *lphe;
lphe = gethostbyname("mylinux");
if (!lphe) {
} else {
printf("Computer name is : %s\nIts IP address is: %s", lphe->h_name, inet_ntoa(lphe->h_addr));
}
Hope that helps a bit...
Regards
|
|
|
|
|
Galatei wrote: lphe = gethostbyname("mylinux");
How / From where I can get this name ("mylinux")?
Galatei wrote: inet_ntoa(lphe->h_addr)
It is giving error that Can't convert to char* from in_addr.
|
|
|
|
|
Aniket Salunkhe wrote: How / From where I can get this name ("mylinux")?
#include <unistd.h>
#include <limits.h>
char name[HOST_NAME_MAX+1];
int result;
result=gethostname(name, HOST_NAME_MAX+1);
|
|
|
|
|
Aniket Salunkhe wrote: name ("mylinux")?
That was just an example.
To get the name of your system, simply call getenv("HOSTNAME") which will give you full name of your system in return.
example:
printf("HOSTNAME: %s\n", getenv("HOSTNAME"));
In order to read address of particular interface (eg. eth0), you may do something like this:
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int getifaddr(char *pifname, struct sockaddr_in* psai)
{
int s;
struct ifreq ifr;
struct sockaddr_in *saitmp = (struct sockaddr_in*)&ifr.ifr_addr;
if (!pifname || !psai)
return -1;
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0)
return -2;
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, pifname);
saitmp->sin_family = AF_INET;
if (ioctl(s, SIOCGIFADDR, &ifr) != 0)
return -3;
memcpy(psai, saitmp, sizeof(struct sockaddr_in));
return 0;
}
then use inet_ntoa function to get address string.
example:
#include <stdio.h>
#include <string.h>
int main(void)
{
struct sockaddr_in sai;
if (!getifaddr("eth0", &sai))
printf("IP: %s\n", inet_ntoa(sai.sin_addr));
else
perror("getifaddr error!\n");
}
Hope that helps.
Regards
|
|
|
|
|
Thanks.
Now I am getting proper System IP in Linux; & also the System Name.
|
|
|
|
|
Hi!
there is a ListControl in my project (FormView).
if user selects an Item or more, rows of this items in ListControl, take different color.
But, if user kill focuse of list control, color of this items change to same color of other items.
what do i do to solve this problem?
Zo.Naderi-Iran
|
|
|
|
|
Do you need to add the LVS_SHOWSELALWAYS style?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i add this style, but it isn't useful.
Zo.Naderi-Iran
|
|
|
|
|
excuse me, i find Show selection always in style tab of properties of List control and select this property, now my problem is solved.
Thanks alot
Zo.Naderi-Iran
|
|
|
|
|
Dear all
I write a small project with visual C++ 6.0.
when I test the program on my computer, it works properly and when I want to close it, it closes without any error
But after I transfer the exe file (debug version and not release version) to another computer, when I want to close the program , it shows a (Retry, Abort , ignore) message box about heap error.
In second computer I copy the visual C++ dlls near the executable file.
May you please help me how this problem occures and what is the reson of it.
Regards
Mahdi
|
|
|
|
|
Hi,
it is possible that buffer overrun/underrun occurs in your code, causing such error.
Check your code for buffer lengths and/or possibilities that memory is not allocated or reallocated without being released.
m_monhi wrote: what is the reson of it.
The reason is probably your debug environment, which is more flexible and forgiving than any production environment.
hope that helps a bit
Best regards
|
|
|
|
|
Maybe you used of a service is install in your computer and not other computers?
|
|
|
|
|
I tried function keybd_event() to simulate ALT key stroke.
It works Ok in Windows XP but I need it use also in Win95
(that's why I am using keaybd_event instead of SendInput)
But it doesn't works (it works fain for normal keys but not for ALT)
I was using VK_LMENU and VK_MENU
Actualy I need too simulate ALT+F and such abbreviation key.
Does enyone know how - or other way to simulate key strokes?
thank you
viliam
|
|
|
|
|
You can try using PostMessage() and post keyboard events to the active window (you may get it with GetActiveWindow() ).
Please go through this article[^] also. I haven't gone through it completely to see if the author is using SendInput or keybd_event but I think it can be of some use to you.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I created a tree control which displays the files and folders similar to the explorer.when i want to display a single folder i gave the path to that folder so that it has been displayed in the treecontrol.My question is can we display the required folder without giving the path for it i.e,the application should only search where the folder exists in various drives.
Thanks.
|
|
|
|
|
radhika28 wrote: I created a tree control which displays the files and folders similar to the explorer.when i want to display a single folder i gave the path to that folder so that it has been displayed in the treecontrol.My question is can we display the required folder without giving the path for it i.e,the application should only search where the folder exists in various drives.
Please rephrase your question.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I have created an sdi application using form view.In that i have placed a tree control.I have added code so that the tree control displays files and folders similar to the explorer tree.If we want a particular folder to be displayed if we give the path in the code i.e,"F:\\My Favourites\\",we get that folder displayed.Now i want to make my application for the usage in the other systems also.But My favourites folder will be placed in other computers as for the wish of the user.So i want to add code such that My Favourites folder should be displayed in the tree control irrespective of giving the path to display that folder.
Thanks.
|
|
|
|
|
When you do not know where the folder is, may be for the first time you could ask the user to browse for that particular folder. Then store this path in your applications information settings file (if you are using one) or in the registry. The next time, you could lookup this information and load the folder. In case of a failure event later (The folder may not exist because the user removed/renamed/moved it), again ask the user to browse for the folder.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hi,
I think that SHGetSpecialFolderLocation, SHGetSpecialFolderPath are function you're looking for. By specifying CSILD of requested folder (CSIDL for "My Favourites" is CSIDL_FAVORITES) you can obtain full path to its location on the disk.
Regards
|
|
|
|