Saiskohan jollain koodilla tietää esim. Mihin kansioon on Windows asennettu tai että missä on ohjelmatiedostot?
Windows-kansion saa ainakin selville API-funktiolla GetWindowsDirectory. Program Files -kansiosta ei ole tietoa.
Kappaleessa A-2 on kansioiden nimet (W2000):
http:// msdn.microsoft.com/library/en-us/dnw2ksrv/html/w2kserve_appa.asp
...ja tässä copypaste MSDN:stä (ei löytynyt microsoftilta enää...)
lainaus:
Step-by-Step Example
In Visual Basic, start a new Standard EXE project. Form1 is created by default.Add a CommandButton and a TextBox control to Form1.
In the General Declarations Section of the code window for Form1, paste the following code:
Option Explicit Private Const S_OK = &H0 ' Success Private Const S_FALSE = &H1 ' The Folder is valid, but does not exist Private Const E_INVALIDARG = &H80070057 ' Invalid CSIDL Value Private Const CSIDL_LOCAL_APPDATA = &H1C& Private Const CSIDL_FLAG_CREATE = &H8000& Private Const SHGFP_TYPE_CURRENT = 0 Private Const SHGFP_TYPE_DEFAULT = 1 Private Const MAX_PATH = 260 Private Declare Function SHGetFolderPath Lib "shfolder" _ Alias "SHGetFolderPathA" _ (ByVal hwndOwner As Long, ByVal nFolder As Long, _ ByVal hToken As Long, ByVal dwFlags As Long, _ ByVal pszPath As String) As Long Private Sub Command1_Click() Dim sPath As String Dim RetVal As Long ' Fill our string buffer sPath = String(MAX_PATH, 0) RetVal = SHGetFolderPath(0, CSIDL_LOCAL_APPDATA Or CSIDL_FLAG_CREATE, 0, SHGFP_TYPE_CURRENT, sPath) Select Case RetVal Case S_OK ' We retrieved the folder successfully ' All C strings are null terminated ' So we need to return the string upto the first null character sPath = Left(sPath, InStr(1, sPath, Chr(0)) - 1) Text1.Text = sPath Case S_FALSE ' The CSIDL in nFolder is valid, but the folder does not exist. ' Use CSIDL_FLAG_CREATE to have it created automatically MsgBox "The folder does not exist" Case E_INVALIDARG ' nFolder is invalid MsgBox "An invalid folder ID was specified" End Select End SubPress the F5 key to run the project.
Click the CommandButton control. The TextBox control is filled with the path to the current user's Application Data folder.
Note that the CSIDL_FLAG_CREATE flag is used. If the folder does not exist, then the SHGetFolderPath function creates it for you, fills the string buffer with the path, and returns S_OK. If you do not use the CSIDL_FLAG_CREATE flag, and the folder does not exist, then the SHGetFolder function returns S_FALSE and nothing is placed in your string buffer. To find the location of other special folders, you need to change the nFolder parameter to another CSIDL value. The constants for these values can be found on the MSDN.
Juuh, kyllähän tossa oli, mutta meinasin että ihan parilla rivillä. Ei taida tosin olla mahdollista.
Mistä muuten hankit ton MSDN:n.
Olen ettinyt KaZaAsta, mutta ei tunnu löytyvän toimivaa versiota.
Mahtaako olla kaupasta ostettuna kallis?
Kaupasta ostettuna MSDN maksaa vaikka mitä, mutta Internetin kautta sen käyttäminen on ilmaista:
Käyttöliittymä on tosin melko hidas Internet-versiossa.
Se on todella kallis paketti, mutta teen tätä työkseni ja siksipä se pitää olla ;)...
Aihe on jo aika vanha, joten et voi enää vastata siihen.