473,811 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compiling a simple ShellExecute with C

Having problems compiling the following code in C USING CL.EXE
// shell.c LANGUAGE = .NET 2003
#include <iostream.h>
#include <windows.h>

int main()
{
SHELLEXECUTE(NU LL, "open", "notepad.ex e", NULL, NULL, SW_SHOWNORMAL);
RETURN 0;
}

Results:

C:\ CL /EHs shell.c
....... Incremental Linker Version 6.00.8447
......
shell.obj : error LNK2001: unresolved external symbol __imp__ShellExe cuteA@24
shell.exe : fatal error LNK1120: 1 unresolved externals
C:\>

I suppose the problem has to do with Unicode. but am not sure. Any help
appreciated.

Thanks,

Hank

Dec 4 '07 #1
5 3024
SHELLEXECUTE(NU LL, "open", "notepad.ex e", NULL, NULL, SW_SHOWNORMAL);
The function is called ShellExecute, not SHELLEXECUTE.

>C:\ CL /EHs shell.c
...... Incremental Linker Version 6.00.8447
.....
shell.obj : error LNK2001: unresolved external symbol __imp__ShellExe cuteA@24
shell.exe : fatal error LNK1120: 1 unresolved externals
Try adding

/link shell32.lib

Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 4 '07 #2
hkMicro wrote:
Having problems compiling the following code in C USING CL.EXE
// shell.c LANGUAGE = .NET 2003
#include <iostream.h>
#include <windows.h>

int main()
{
SHELLEXECUTE(NU LL, "open", "notepad.ex e", NULL, NULL, SW_SHOWNORMAL);
RETURN 0;
}

Results:

C:\ CL /EHs shell.c
...... Incremental Linker Version 6.00.8447
.....
shell.obj : error LNK2001: unresolved external symbol __imp__ShellExe cuteA@24
shell.exe : fatal error LNK1120: 1 unresolved externals
C:\>

I suppose the problem has to do with Unicode. but am not sure. Any help
appreciated.
Hank:

Note that iostream (which you are not actually using) is C, not C++. And
<iostream.his an obsolete header (use <iostream>).

You are not really in the right group; use microsoft.publi c.vc.language
for questions that do not have to do with.NET.

--
David Wilkinson
Visual C++ MVP
Dec 4 '07 #3
David Wilkinson wrote:
Hank:

Note that iostream (which you are not actually using) is C, not C++. And
<iostream.his an obsolete header (use <iostream>).

You are not really in the right group; use microsoft.publi c.vc.language
for questions that do not have to do with.NET.
Of course I meant: iostream is C++, not C.

--
David Wilkinson
Visual C++ MVP
Dec 4 '07 #4
Hi Hank,

Yes, this is because <Windows.hinclu des a lot of important(or must have)
windows header files, such as <windef.h>, <winbase.hetc.. . These files
define must of the windows structures types, such as DWORD, BOOL etc..

So we'd better always include <windows.hif you are programming Windows
SDK applications. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 5 '07 #5
Hi Hank,

Have you reviewed all the replies to you? If you still need any help or
have any concern, please feel free to feedback, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Dec 10 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2568
by: Marcel Sammut | last post by:
Greetings, I am converting a VB6 application to .net and am having troubles trying to print a document directley to the printer. My VB6 app used the API ShellExecute method to accomplish this, however, needed the printer name, driver and port. All which were obtainable using the Printer object in VB6. Now in .net, I've tried using the System.Drawing.Printing namespace to do this, but that is unsatisfactory. So I went back to the API...
3
5475
by: Wiktor Zychla | last post by:
I have a problem I cannot solve. My application hosts IE activex control. I follow the standard procedure: I just aximp shdocvw.dll. Note that this gives you two files: axshdocvw.dll and shdocvw.dll. And there comes the problem. I reference the libraries from my project. For this to work, I put the libraries in the same directory as the application. Now, from my code I try to ShellExecute to a link (to show it in a new window):
1
2315
by: MCzajk | last post by:
Is there a function similar to ShellExecute, which I can hook to when the program is started using Start Menu icon? MCzajk
0
1837
by: the_openFace | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd, string lpOperation, string lpFile,
0
1600
by: the openBack | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd, string lpOperation, string lpFile,
0
1860
by: David | last post by:
We have an mfc application in which we use ShellExecute to launch the browser with an initial web site. {ShellExecute( NULL, "open", "http://www.SomeWebSite.com", NULL, NULL, SW_SHOWNORMAL ) } This always worked without problems until... We have modified the application so that it now contains some managed C++ and C# code (in dll's). The call to ShellExecute is in an unmanaged C++ dll. When trying
3
1535
by: Fred | last post by:
Hi, I have an Excel add-in and an ActiveX component and a script which puts the add-in in the XLStart directory and installs and registers the ActiveX component. Basically the script is my install program. The problem is that I believe the Autorun.inf file on a CD to autostart can only call exe files? I presume this is correct. How can I create a simple .exe file to run my script assuming that some PCs won't have Framework installed. ...
1
3932
by: jon2211 | last post by:
I tried to compile some code with #include <shellapi.h. I am linking shell32.lib. I am not trying to use ShellExecute() but right now just getting the code to compile with the header file an issue. I am using Visual Basic 2005 (express). I got shellapi.h from the platform sdk. Thanks for any help. here is my error log 1>------ Build started: Project: openFile, Configuration: Debug Win32 ------
2
10744
by: John Smith | last post by:
Hi, I have an access database form with an image. I'm trying to create an onclick event on the image so that when a user clicks on the image it opens that file with the default viewer the computer is set on. I've searched the web and nothing solid. I did get the following VBA code and it doesn't seem to work. If anyone can help me i'd appreciate it. From the code below txtImageNote is a field on the form that displays the path to...
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10124
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.