?
Solved

Create DLL File- In Any Language

Posted on 2007-07-21
13
Medium Priority
?
466 Views
Last Modified: 2012-08-13
I have code that I need to make into a dll file.  I can write the dll file in a number of different languges.  So please let me know how to do this in any language (I prefer a Visual Studio. Net Language though).  

I wanted to kindly ask if you could let me know step by step how to navigate in the interface to do this and create the dll file.  
0
Comment
Question by:jjrr007
  • 6
  • 4
  • 2
12 Comments
 
LVL 6

Expert Comment

by:thuannguy
ID: 19539892
Hi,
Open the visual studio, then the File menu -> New -> Project... -> select Visual C# or Visual Basic on the Project types group and then select Class Library on the Templates window
BR,
thuannguy.
0
 
LVL 1

Author Comment

by:jjrr007
ID: 19542592
Thanks Thuannguy for your assistance  I guess I'm not that good at coding in C# as I thought.  I'm getting the following erros when I tried.  What do you suggest I do so this can work?  

Type or namespace definition, or end-of-file expected
Expected class, delegate, enum, interface, or struct
Expected class, delegate, enum, interface, or struct

The code is below:
using System;
namespace ClassLibrary1
{
    public Class1
      {
      public RunBatFile()
            {
           Shell("D:\Directory\batfile.bat");
            End;
      }
      }
}
0
 
LVL 1

Author Comment

by:jjrr007
ID: 19542648
I have the errors reduced to just one.  The error and code is below.  What do you suggest?

Error:
4): A namespace does not directly contain members such as fields or methods

Code:
using System;
namespace ClassLibrary1
{
Public RunBatFile()
Shell("D:\Directory\batfile.bat");
End;
}

It would be nice for the dll file to return the number 1 when finished- but I'm not sure of the syntax for that.  Any ideas?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Expert Comment

by:thuannguy
ID: 19542742
Hi,
You must put your code inside a method of a class like in your second post, but there is no End; at the end:
using System;
namespace ClassLibrary1
{
      public Class1
      {
            public int RunBatFile()
            {
                       Shell("D:\Directory\batfile.bat");
                       return 1;
             }
      }
}
0
 
LVL 1

Author Comment

by:jjrr007
ID: 19543300
Thanks a lot for your time.

I have just tried the code provided.  I am getting the following build errors:

(12): Type or namespace definition, or end-of-file expected
(4): Expected class, delegate, enum, interface, or struct
(6): Expected class, delegate, enum, interface, or struct

What do you suggest?  Thanks again!

0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 19545556
You may add a command handler for the help button, like this

e.g.

BEGIN_MESSAGE_MAP(CPageWithHelp, CPropertyPage)
//{{AFX_MSG_MAP(CPageWithHelp)
//}}AFX_MSG_MAP
ON_COMMAND(ID_HELP, OnHelp)
END_MESSAGE_MAP()

void CPageWithHelp::OnHelp()
{
HtmlHelp(NULL, _T("C:\\testhelp.chm"), HH_DISPLAY_TOPIC, 0);
}


This should enable the help button on activating the property page.

The HtmlHelp function call requires:
#include "Htmlhelp.h"

and in the project settings, tab "link", entry "object/library modules":htmlhelp.lib


See knowledge base article:
HOWTO: Set Up Visual C++ to Use the HTML Help API
http://support.microsoft.com/kb/186907


For how to produce compiled html (".chm") files. You may check the page:
http://msdn2.microsoft.com/en-us/library/ms670169.aspx


-MAHESH
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 19545559
oops  !!!!  sorry post in wrong thread......Sorry !
0
 
LVL 6

Expert Comment

by:thuannguy
ID: 19548459
Oops, sorry!
using System;
namespace ClassLibrary1
{
      public class Class1            //<--- miss a "class" keyword here
      {
            public int RunBatFile()
            {
                       Shell(@"D:\Directory\batfile.bat");  //<--- need '@'
                       return 1;
             }
      }
}

I still wonder what the Shell function is :P
0
 
LVL 1

Author Comment

by:jjrr007
ID: 19552254
Thanks for your time. I'm getting the following error, when I compiled the code above:

(8): The name 'Shell' does not exist in the class or namespace 'ClassLibrary1.Class1'

What the code above is suppose to do is open a bat file and when it's complete return a 1.  I used the Shell function to open a bat file.  Should I use something else?  If so, what would you recommend (I have to do this in a DLL file).  

Thanks again!
0
 
LVL 6

Accepted Solution

by:
thuannguy earned 2000 total points
ID: 19556525
Yeah, the Shell function is not available in .NET:

using System;
namespace ClassLibrary1
{
      public class Class1
      {
            public int RunBatFile()
            {
                       System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo(@"D:\Directory\batfile.bat");
                       System.Diagnostics.Process proc = new System.Diagnostics.Process();
                       proc.StartInfo = p;
                       proc.Start();
                       proc.WaitForExit();

                       return 1;
             }
      }
}
0
 
LVL 1

Author Comment

by:jjrr007
ID: 19588376
Thanks a lot for your assistance thuannguy.  I appreciate your assistance!
0
 
LVL 1

Author Comment

by:jjrr007
ID: 19588385
I apologize for the delay in the delay.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Integration Management Part 2
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question