Alex
Mon Jul 18 17:58:50 CDT 2005
Oh, right... I somehow assumed (instead of reading the post, I guess) that
he wanted the dll path. Yes, of course it's
Server.MapPath(Request.ServerVariables("SCRIPT_NAME"))
--
Alex Feinman
---
Visit
http://www.opennetcf.org
"John Spaith [MS]" <jspaith@ONLINE.microsoft.com> wrote in message
news:%23FkGJ87iFHA.3288@TK2MSFTNGP09.phx.gbl...
> There's no way that the COM object can directly determine the ASP page
> that is invoking into it. As far as the COM object you've written knows,
> it's being called from a standard C++ executable and not from the ASP
> script engine. So you'd need ASP itself to get the page information to
> the client.
>
> I think you'd want something like below (note I haven't tried this myself
> so I may not have it quite right)
>
> Set urlPath = Request.Variables("SCRIPT_NAME"); ' this gets you virtual
> name of ASP page
> Set fileName = Server.MapPath(urlPath); ' this maps virtual name ->
> physical name
>
> --
> John Spaith
> Software Design Engineer, Windows CE
> Microsoft Corporation
>
> Check out the new CE Networking Team Blog at
http://blogs.msdn.com/cenet/.
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> You assume all risk for your use. © 2003 Microsoft Corporation. All rights
> reserved.
>
> "Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
> news:OSMBjL7iFHA.3256@TK2MSFTNGP12.phx.gbl...
>> That's because GetModuleFileName(0, ... ) returns the name of the calling
>> process' executable, and not the calling module's.
>> On XP and W2K3 try replacing the call to GetModuleFileName with
>>
>> static int i = 0;
>> GetModuleHandleExGET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_UNCHANGED_REFCOUNT,
>> (LPCTSTR)&i, &hModule);
>>
>> If you need this on W2K and NT4, you will need to use toolhelp library to
>> enumerate all modules for the current process and see if the address
>> inside your current module (like an address of a static variable above)
>> falls inside the memory range
>>
>>
>> --
>> Alex Feinman
>> ---
>> Visit
http://www.opennetcf.org
>> "Chan" <parkchan@hotmail.com> wrote in message
>> news:1121698195.039991.134360@z14g2000cwz.googlegroups.com...
>>> Hello All,
>>>
>>> I'm trying to write an ATL COM to be used with an ASP on Windows CE
>>> Environment.
>>> I want to get the full path of an ASP file which calls the COM dll. In
>>> my COM, I have a method called "MapPath" which is meant to return the
>>> full path of an ASP file.
>>>
>>> STDMETHODIMP CFile::MapPath(BSTR *strVal)
>>> {
>>> AFX_MANAGE_STATE(AfxGetStaticModuleState())
>>>
>>> // TODO: Add your implementation code here
>>> TCHAR filepath[MAX_PATH];
>>> ::GetModuleFileName (0, filepath, sizeof (filepath));
>>>
>>> CComBSTR bstr (filepath);
>>> *strVal = bstr.Detach();
>>>
>>> return S_OK;
>>> }
>>>
>>> The ASP file instantiates the COM object and calls the method.
>>>
>>> Set objFile = CreateObject ("Object.File")
>>> ==> Response.Write objFile.MapPath
>>> Set objFile = Nothing
>>>
>>> When the asp file invokes the method (indicated by an arrow) I expect
>>> the method to return the full path of the ASP file
>>> ("\Windows\www\wwwpub\file\test.asp"). However, the MapPath method
>>> returns "\Windows\services.exe".
>>>
>>> I suppose there should be more lines of code to retrieve the caller's
>>> full path but don't know what and how.
>>>
>>> I'm very new to VC++. Could you post some code example here please?
>>>
>>> Thank you very much,
>>> Chan
>>>
>>
>
>