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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET /C# and API Calls...

Status
Not open for further replies.

wsmall73

Programmer
May 23, 2002
261
US
I wanted to know if it is possible to make API Calls from ASP.NET... I am looking to convert our screen scrape utility (HLLAPI) from PowerBuilder to the web. I had read somewhere in the past that you couldn't access DLL's on the client PC for security purposes and wonder with .NET if there was a way to do this now? We are using C#. TIA
 
You can call external DLL functions by doing code like this:
Code:
[DllImport("KERNEL32.DLL", EntryPoint="MoveFileW",  SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool MoveFile(String src, String dst);

But as you noted, security is a concern. Your users will have to go into the .NET admin tool (Start | Programs | Administrative Tools | Microsoft .NET Framework Configuration) and specially allow your assembly to call local DLL. For safety, you need to supply them with either your public certificate info (Name, Issuer Name, Hash value), or the strong name for your assembly (if you download it to their PC).

Chip H.


 
Thanks for responding chip...

Each user has to do this?? We are looking at approximately 2000 users... and if the DLL is not one that we created how would I determine the public certificate info or the strong name for the assembly... as always thanks in advance...
 
Each user has to do this??

Yes. You're accessing *their* PC, after all. One possibility to lighten your load is if a large number of users are in a particular company, you can get the IT department there to assign rights to your assembly via the Enterprise part of the security permissions tree. That'll save them some effort.

If you're accustomed to the old "OCX" way of doing things (as long as your OCX was trusted, you could do anything to a user's PC), those days are gone. Users who didn't know any better ended up installing spyware (Gator) on their PCs, and the corporate IT people had no control.

Chip H.
 
Thanks Chip I have been dying to ask someone these questions... I was thinking that we may be able to hack the registry and accomplish this as well. Possible? Sorry for all the questions... I am dying to put PB to bed and get moving with C# and ASP.Net and because most of our applications utilize several API calls this seems to be a hanging point for us. TIA
 
I don't think you can tweak the registry to allow you to call the API functions. - I don't think the info is stored there. You might want to do a search in the MSDN knowledgebase, and if that fails, post it to webqa@microsoft.com.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top