荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: tang (独孤九剑), 信区: Program
标  题: MSVC-BEGINNERS Digest - 19 May 1998 to 20
发信站: BBS 荔园晨风站 (Thu May 21 23:56:05 1998), 转信

There are 12 messages totalling 530 lines in this issue.

Topics of the day:

  1. Win32 App  to create a few second pause. (6)
  2. Visual Interdev Question
  3. coping files (4)
  4. HELP! Can't get started.
What application type are you using? You should be using a Console
application for your project.

/Anders W

> -----Original Message-----
> From: Wayne M. VanWeerthuizen [SMTP:WayneMV@LOCALACCESS.COM]
> Sent: den 19 maj 1998 17:52
> To:   MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
> Subject:      Re: [MSVC] Win32 App  to create a few second pause.
>
> On Tue, 19 May 1998 12:33:01 +0200, Anders W録lin wrote:
>
> >Have you tried to include "windows.h"?
>
> Yes, I'm now using:
>
>     #include <windows.h>
>     #include <winbase.h>
>
>     int main(int argc, char *argv[])
>     {
>         Sleep(atoi(argv[1])*1000);
>         return(0);
>     }
>
>
> But I get these two errors:
>
> LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol
> _WinMain@16
>
> Debug/Sleep.exe : fatal error LNK1120: 1 unresolved externals
>
>
> I very disappointed in MSVC's online documentation.  Hardly any of its
> labels or header files are listed in the help index.  And I can't find
> anything about writing a Win32 application using the API directly
> without the MFC.  Decent documentation should at least give me an
> example of the minimum code needed for a non-MFC "Hello World"
> program.
>
> >>>> I created a minimal workspace by using
> >>>>   New | Project | Win32 Application
> >>>>
> >>>> I want a minimal Windows application that exists for a spe
cified
> >>>> number of seconds, then terminates.  I don't want it to di
splay
> any
> >>>> (visible) windows.  It will be called by a another Windows

> >>>> application (that  I didn't write and don't have the sourc
e code
> >>>> for), which would wait for it to finish.  The delay is nee
ded for
> >>>> me to work around a bug in this other program.
>
> Note:  I cannot write a console application and call it via a
> shortcut.  In that case, this other program won't wait for it to
> finish.
On Wed, 20 May 1998 08:04:49 +0200, you wrote:

>What application type are you using? You should be using a Console
>application for your project.
>
>/Anders W

That will display an unwanted window.  If I call it via a shortcut
that makes the window minimize, then the program that calls mine won't
respect the pause.

>> -----Original Message-----
>> From: Wayne M. VanWeerthuizen [SMTP:WayneMV@LOCALACCESS.COM]
>> Sent: den 19 maj 1998 17:52
>> To:   MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
>> Subject:      Re: [MSVC] Win32 App  to create a few second pause.
>>
>> On Tue, 19 May 1998 12:33:01 +0200, Anders W録lin wrote:
>>
>> >Have you tried to include "windows.h"?
>>
>> Yes, I'm now using:
>>
>>     #include <windows.h>
>>     #include <winbase.h>
>>
>>     int main(int argc, char *argv[])
>>     {
>>         Sleep(atoi(argv[1])*1000);
>>         return(0);
>>     }
>>
>>
>> But I get these two errors:
>>
>> LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol
>> _WinMain@16
>>
>> Debug/Sleep.exe : fatal error LNK1120: 1 unresolved externals
>>
>>
>> I very disappointed in MSVC's online documentation.  Hardly any of its
>> labels or header files are listed in the help index.  And I can't find
>> anything about writing a Win32 application using the API directly
>> without the MFC.  Decent documentation should at least give me an
>> example of the minimum code needed for a non-MFC "Hello World"
>> program.
>>
>> >>>> I created a minimal workspace by using
>> >>>>   New | Project | Win32 Application
>> >>>>
>> >>>> I want a minimal Windows application that exists for a
 specified
>> >>>> number of seconds, then terminates.  I don't want it t
o display
>> any
>> >>>> (visible) windows.  It will be called by a another Win
dows
>> >>>> application (that  I didn't write and don't have the s
ource code
>> >>>> for), which would wait for it to finish.  The delay is
 needed for
>> >>>> me to work around a bug in this other program.
>>
>> Note:  I cannot write a console application and call it via a
>> shortcut.  In that case, this other program won't wait for it to
>> finish.
Wayne M. VanWeerthuizen wrote:

> But I get these two errors:
>
> LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol
> _WinMain@16
>
> Debug/Sleep.exe : fatal error LNK1120: 1 unresolved externals
>
... snip snip
>
> >>>> I created a minimal workspace by using
> >>>>   New | Project | Win32 Application
> >>>>
> >>>> I want a minimal Windows application that exists for a spe
cified
> >>>> number of seconds, then terminates.  I don't want it to di
splay any
> >>>> (visible) windows

... more snip snip

> Note:  I cannot write a console application...

Your program won't link because the entry point for a Win32 program is
WinMain(), not main().    (main() will work in a console app).
Since you feel you need Win32, do this:

#include <windows.h>

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                                        PSTR szCmdLine, int iCmdShow)
{
        MessageBeep(0xFFFFFFFF);        // this is here so I know it works
        Sleep(atoi(szCmdLine)*1000);
        MessageBeep(0xFFFFFFFF);        // ditto
        return 0;
}

Search the docs on WinMain(). Note that szCmdLine will contain the
command line EXCLUDING argv[0];
So if you execute the program in DevStudio, argc is effectively 1,
szCmdLine will be an
empty string and atoi() will return 0 (Check the docs for atoi). If you
use the run facility (under
Start on the taskbar), you can optionally add a value (argv[1]) to
achieve what you were trying to do.
Something like: c:\path stuff here\MyProg.exe 4  - this will give you
roughly 4 seconds between beeps.

Hope this helps,

Douglas Gilbert,
Calgary, Alberta.
Try to change  int main(int argc, char *argv[])
to WinMain and change the parameters like the online documentation says


>-----Original Message-----
>From:  Wayne M. VanWeerthuizen [SMTP:WayneMV@LOCALACCESS.COM]
>Sent:  Tuesday, May 19, 1998 5:52 PM
>To:    MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
>Subject:       Re: [MSVC] Win32 App  to create a few second pause.
>
>On Tue, 19 May 1998 12:33:01 +0200, Anders W録lin wrote:
>
>>Have you tried to include "windows.h"?
>
>Yes, I'm now using:
>
>    #include <windows.h>
>    #include <winbase.h>
>
>    int main(int argc, char *argv[])
>    {
>        Sleep(atoi(argv[1])*1000);
>        return(0);
>    }
>
>
>But I get these two errors:
>
>LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol
>_WinMain@16
>
>Debug/Sleep.exe : fatal error LNK1120: 1 unresolved externals
>
>
>I very disappointed in MSVC's online documentation.  Hardly any of its
>labels or header files are listed in the help index.  And I can't find
>anything about writing a Win32 application using the API directly
>without the MFC.  Decent documentation should at least give me an
>example of the minimum code needed for a non-MFC "Hello World"
>program.
>
>>>>> I created a minimal workspace by using
>>&gt;>>   New | Project | Win32 Application
>>>>>
>>>>> I want a minimal Windows application that exists for a spec
ified
>>>>> number of seconds, then terminates.  I don't want it to dis
play any
>>>>> (visible) windows.  It will be called by a another Windows
>>>>> application (that  I didn't write and don't have the source
 code
>>>>> for), which would wait for it to finish.  The delay is need
ed for
>>>>> me to work around a bug in this other program.
>
>Note:  I cannot write a console application and call it via a
>shortcut.  In that case, this other program won't wait for it to
>finish.
I don't know why you are making this a big Mark.

I created a test.cpp file with the following code.
//TEST.cpp
#include <windows.h>
#include <winbase.h>

int main(int argc, char *argv[])
{
     Sleep(atoi(argv[1])*1000);
     return(0);
}

and compiled by the following command:
cl test.cpp
and run the application by following arguments:
test 5
it is working properly.

Can you explain from where you are getting the window:
Oh, Yah, if you run though Developer studio it runs the exe as a shortcut. Then
It will show the results in the window. It doesn't mean that the application
buil
t the window, which is a Dos window.

But if you run from the dos prompt you will get clear idea about it..

Hope you got the point.


-----Original Message-----
From:   Wayne M. VanWeerthuizen [SMTP:WayneMV@LOCALACCESS.COM]
Sent:   Wednesday, May 20, 1998 12:06 PM
To:     MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
Subject:        Re: [MSVC] Win32 App  to create a few second pause.

On Wed, 20 May 1998 08:04:49 +0200, you wrote:

>What application type are you using? You should be using a Console
>application for your project.
>
>/Anders W

That will display an unwanted window.  If I call it via a shortcut
that makes the window minimize, then the program that calls mine won't
respect the pause.

>> -----Original Message-----
>> From: Wayne M. VanWeerthuizen [SMTP:WayneMV@LOCALACCESS.COM]
>> Sent: den 19 maj 1998 17:52
>> To:   MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
>> Subject:      Re: [MSVC] Win32 App  to create a few second pause.
>>
>> On Tue, 19 May 1998 12:33:01 +0200, Anders W録lin wrote:
>>
>> >Have you tried to include "windows.h"?
>>
>> Yes, I'm now using:
>>
>>     #include <windows.h>
>>     #include <winbase.h>
>>
>>     int main(int argc, char *argv[])
>>     {
>>         Sleep(atoi(argv[1])*1000);
>>         return(0);
>>     }
>>
>>
Hi All,

I know this isn't for this list but does anyone know of a good book on Visual
Interdev or even a list I could join.

Thanks

Mark.
Hello,
    Is there an easy way to copy files from one drive to another just like
the dos command copy.I don`t seem to be able to find it anywhere.

Thanks in advance Shay.
Look for "SHFileOperation"

WINSHELLAPI int WINAPI SHFileOperation(LPSHFILEOPSTRUCT lpFileOp);

Copies, moves, renames, or deletes a file system object.

Returns zero if successful, or nonzero otherwise.
lpFileOp
Address of an SHFILEOPSTRUCT structure that contains information this
function needs to carry out the specified operation.


> -----Original Message-----
> From: MSVC-BEGINNERS [mailto:MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU]On
> Behalf Of Shay Forde
> Sent: Wednesday, May 20, 1998 7:05 AM
> To: MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
> Subject: [MSVC] coping files
>
>
> Hello,
>     Is there an easy way to copy files from one drive to another just like
> the dos command copy.I don`t seem to be able to find it anywhere.
>
> Thanks in advance Shay.
>
Hi,


> Is there an easy way to copy files from one drive to another just like
> the dos command copy.I don`t seem to be able to find it anywhere.


Maybe, but I don't know of a good one for MFC. However, if you don't mind a
little WIN32 coding lookup SHFILEOPSTRUCT and SHFileOperation. This shell
namespace struct can be used for more than just copying and will display a
progress dialogues if you want.

Hope it helps.

Scot
HI,

Just one last comment.

No matter what you do, this application is not going to put any delay in the
processor. So it'd probably be best to spawn the other application from the
delay program. Investigate the ShellExecuteEX function and the
SHELLEXECUTEINFO structure.

Scot
hi!!!
I have used the Win32 API function CopyFile for the same proposal...
Hope I don't sound stupid.. :)
bye

regards: aceh




-----Original Message-----
From:   Scot Nielsen [SMTP:qakec@WESTMINSTER.AC.UK]
Sent:   Wednesday, May 20, 1998 2:01 PM
To:     MSVC-BEGINNERS@MAELSTROM.STJOHNS.EDU
Subject:        Re: [MSVC] coping files

Hi,


> Is there an easy way to copy files from one drive to another just like
> the dos command copy.I don`t seem to be able to find it anywhere.


Maybe, but I don't know of a good one for MFC. However, if you don't mind a
little WIN32 coding lookup SHFILEOPSTRUCT and SHFileOperation. This shell
namespace struct can be used for more than just copying and will display a
progress dialogues if you want.

Hope it helps.

Scot
I am learning MSVC on my own.  I have read a few books and have MSVC++
5.0 but I am having trouble getting started.

After reading (and reading and reading) I decided that I would put my
knowledge to use and attempt to create a very simple card game (thinking
it would be easiest since I have created several for Visual Basic
already).  I can't seem to get the thing to work.  I believe I am still
thinking too much like Visual Basic.  Does anyone have a sample card
game I can look at so get some idea on which direction I should be
going?

This is strictly for learning.  Any help would be appreciated.

Unless you think other may benefit from this you can reply directly to
me at John.Runions@cognos.com.

Thankyou.
_______________________________________
John Runions
Cognos Inc
Quality Control Specialist
<mailto:John.Runions@Cognos.com>
--
        There are these few times I feel lonely for you.
        But I know this shade of blue will soon pass through!
        I must be strong without you by my side!
        I can see forever you are my light.

※ 来源:.BBS 荔园晨风站 bbs.szu.edu.cn.[FROM: 192.168.0.4]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店