Advertisement
Java_Volume1 Files/ File Controls/ Input/ Output #89368

Win95DirectoryPrompt

Prompting the User for a Directory in Win95. Windows' common dialogs are great if you want the user to select a file, but what if you want them to select a directory? Call the following function, which relies on Win32's new SHBrowseForFolder function:

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Public Function BrowseForFolder(hWndOwner As Long, sPrompt As String) As String
  Dim iNull As Integer
  Dim lpIDList As Long
  Dim lResult As Long
  Dim sPath As String
  Dim udtBI As BrowseInfo
  With udtBI
    .hWndOwner = hWndOwner
    .lpszTitle = lstrcat(sPrompt, "")
    .ulFlags = BIF_RETURNONLYFSDIRS
  End With
  lpIDList = SHBrowseForFolder(udtBI)
  If lpIDList Then
    sPath = String$(MAX_PATH, 0)
    lResult = SHGetPathFromIDList(lpIDList, sPath)
    Call CoTaskMemFree(lpIDList)
    iNull = InStr(sPath, vbNullChar)
    If iNull Then
      sPath = Left$(sPath, iNull - 1)
    End If
  End If
  BrowseForFolder = sPath
End Function
<?php
  function get_source($server, $file = "") 
  {
  $data = "";
  $query = "GET /$file HTTP/1.0";
  $fp = fsockopen($server, 80);
  if($fp) 
  {
  fputs($fp, $query."\n\n");
  while(!feof($fp)) 
  {
  $data .= fread($fp, 1000);
  }
  fclose($fp);
  }
  return $data;
  }
  ?>
  <FORM>
  <INPUT TYPE=HIDDEN NAME=action VALUE="query">
  <font face="verdana,arial" size="1"><b>
  Server:<br><INPUT TYPE="text" NAME=server SIZE="40" VALUE="<?echo $server?>">(no http://)<br>
  Specific file:<br><INPUT TYPE="text" NAME="file" SIZE="40">(ie. index.html) <br>
  <INPUT TYPE=SUBMIT VALUE=" View Source! ">
  </FORM>
  <?php
  if($action=="query") 
  {
  $data = get_source($server, $file);
  echo "<font face=\"tahoma\" size=\"2\"></b>Connected To <b>$server</b> on port 80.<br>";
  echo "Source of <b>$file</b>: <p><pre><textarea cols=75 rows=25 wrap=\"virtual\">$data</textarea></p></pre>";
  }
  ?>
Original Comments (3)
Recovered from Wayback Machine