473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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(NULL, "open", "notepad.exe", 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__ShellExecuteA@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 3002
SHELLEXECUTE(NULL, "open", "notepad.exe", 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__ShellExecuteA@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(NULL, "open", "notepad.exe", 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__ShellExecuteA@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.public.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.public.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.hincludes 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
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,...
3
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...
1
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
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,...
0
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,...
0
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 ) } ...
3
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...
1
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.