Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SelectDirectory Causing Error in SVCHOST.EXE

Status
Not open for further replies.

Malacandra

Programmer
Sep 5, 2005
4
GB
BCB6 C++/ Win XP/
Hi,
I need to get SelectDirectory() to open at the "Desktop" or at least "My Computer" level so other drives can be selected.
I have been trying to get this sorted for ages but with no luck. Working code is :
Code:
    AnsiString PathName="";
    if (SelectDirectory("Select Directory","C:\\",PathName))
    {
        ShowMessage(PathName);
    }
This works fine but if I change the Code to :
Code:
    AnsiString PathName="";
    if (SelectDirectory("Select Directory","MyComputer",PathName))
    {
        ShowMessage(PathName);
    }
I get an error in SVCHOST.EXE in CPU window,
error.jpg

then I Ctrl-F2 out of that, go back to my program and the dialog opens with "My Computer" selected okay.
Would like to know if there is a way of not crashing it or is this a fault in the SHBrowseForFolder API.

Thanks for Looking.....

"Time Is Precious, Waste It Wisely
 
How about:
[tt]
SelectDirectory("Select Directory","",PathName)
[/tt]
 
Thanks Tony for the quick response but I already tried that still no joy.
It turns out this error only happens when I'm running the program from in the IDE during programming.
Once it's compiled and run with the IDE closed the problem goes away??????
A bit of a headache whilst testing but fine for deployment.

Thanks Again.....

"Time Is Precious, Waste It Wisely
 
I got intermitent problems with builder 5 also.
it seems that I can compile a project I have
been working on for some time now and it works fine.
then I add one line of code and the thing goes
poof. it wont run in the IDE. I delete obj, tds
everthing that is not source, even reboot and still
poof. sometimes the code is as nonchalant as

ShowMessage ("error");

but poof it goes. It will run outside of builder
though seemingly with no problems. then I add

int a = 1;

before or after the line and it runs in the IDE.
Int a does not have anything to do with the code,
it just sort of rearanges things I guess. I shake
my head and plan the reinstall I have been putting
off for three years.


TC
 
Helo, I can't use SelectDirectory(.. because it is in english and I need in spanish.
I use:

(in the top of form, I put all but see the coment //)
#define NO_WIN32_LEAN_AND_MEAN // <- Esto

#include <vcl.h>
#pragma hdrstop
//#include <sys\stat.h>
#include <WindowsX.h> // <- y esto
//#include <registry.hpp>
//#include <io.h>
//#include <assert.h>
#include "cActFls.h"
#include "cuAuxTool.h"
//-> #include <FileCtrl.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfActFls *fActFls;
extern ST_MyRs xmd;
//-> const SELDIRHELP = 1000;
//---------------------------------------------------------------------------
(...the function)
//---------------------------------------------------------------------------
String __fastcall TfActFls::SelectDirectorio(String cTl)
{
String cfd;
BROWSEINFO bi;
char WDir[MAX_PATH];
char FolderName[MAX_PATH];
LPITEMIDLIST ItemID;

memset(&bi, 0, sizeof(BROWSEINFO));
memset(WDir, 0, MAX_PATH);
bi.hwndOwner = Handle;
bi.pszDisplayName = FolderName;
bi.lpszTitle = cTl.c_str(); //"Seleccionar Directorio Destino ...";
bi.ulFlags = BIF_USENEWUI;
ItemID = SHBrowseForFolder(&bi);
SHGetPathFromIDList(ItemID, WDir);
GlobalFreePtr(ItemID);
cfd = String(WDir);
return cfd;
}
//---------------------------------

(And I use ...)

String cfd = SelectDirectorio("Indicar Directorio Destino ...");
if (cfd.Length()> 0) {
if (nMD == 0)
xmd.cDs = cfd + "\\" + ExtractFileName(xmd.cOr);
else
xmd.cDs = cfd;

tFD->Text = xmd.cDs;
bSi->Enabled = true;
}
-----------
bye.


(when I use the function)
 
I think the problem here is that the desktop
and mycomputer is not necessarily the directory
structure you think it is. the desktop on window
98 folder is in the c:\windows directory and my
computer is propably somewhwer similiar. my desktop
is a construct and not necessarily a folder.
likewise MY Computer.

TC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top